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

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

Issue 2983823002: Improve hashCode for closures (Closed)
Patch Set: Error handling 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_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 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 // If none exists yet, create one and remember it. 2395 // If none exists yet, create one and remember it.
2396 RawFunction* ImplicitClosureFunction() const; 2396 RawFunction* ImplicitClosureFunction() const;
2397 void DropUncompiledImplicitClosureFunction() const; 2397 void DropUncompiledImplicitClosureFunction() const;
2398 2398
2399 // Return the closure implicitly created for this function. 2399 // Return the closure implicitly created for this function.
2400 // If none exists yet, create one and remember it. 2400 // If none exists yet, create one and remember it.
2401 RawInstance* ImplicitStaticClosure() const; 2401 RawInstance* ImplicitStaticClosure() const;
2402 2402
2403 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const; 2403 RawInstance* ImplicitInstanceClosure(const Instance& receiver) const;
2404 2404
2405 RawSmi* GetClosureHashCode() const; 2405 intptr_t ComputeClosureHash() const;
2406 2406
2407 // Redirection information for a redirecting factory. 2407 // Redirection information for a redirecting factory.
2408 bool IsRedirectingFactory() const; 2408 bool IsRedirectingFactory() const;
2409 RawType* RedirectionType() const; 2409 RawType* RedirectionType() const;
2410 void SetRedirectionType(const Type& type) const; 2410 void SetRedirectionType(const Type& type) const;
2411 RawString* RedirectionIdentifier() const; 2411 RawString* RedirectionIdentifier() const;
2412 void SetRedirectionIdentifier(const String& identifier) const; 2412 void SetRedirectionIdentifier(const String& identifier) const;
2413 RawFunction* RedirectionTarget() const; 2413 RawFunction* RedirectionTarget() const;
2414 void SetRedirectionTarget(const Function& target) const; 2414 void SetRedirectionTarget(const Function& target) const;
2415 2415
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 RawFunction* parent_function() const { return raw_ptr()->parent_function_; } 3065 RawFunction* parent_function() const { return raw_ptr()->parent_function_; }
3066 void set_parent_function(const Function& value) const; 3066 void set_parent_function(const Function& value) const;
3067 3067
3068 // Signature type of this closure function. 3068 // Signature type of this closure function.
3069 RawType* signature_type() const { return raw_ptr()->signature_type_; } 3069 RawType* signature_type() const { return raw_ptr()->signature_type_; }
3070 void set_signature_type(const Type& value) const; 3070 void set_signature_type(const Type& value) const;
3071 3071
3072 RawInstance* implicit_static_closure() const { return raw_ptr()->closure_; } 3072 RawInstance* implicit_static_closure() const { return raw_ptr()->closure_; }
3073 void set_implicit_static_closure(const Instance& closure) const; 3073 void set_implicit_static_closure(const Instance& closure) const;
3074 3074
3075 RawObject* hash() const { return raw_ptr()->hash_; }
3076 void set_hash(intptr_t value) const;
3077
3078 static RawClosureData* New(); 3075 static RawClosureData* New();
3079 3076
3080 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object); 3077 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object);
3081 friend class Class; 3078 friend class Class;
3082 friend class Function; 3079 friend class Function;
3083 friend class HeapProfiler; 3080 friend class HeapProfiler;
3084 }; 3081 };
3085 3082
3086 class SignatureData : public Object { 3083 class SignatureData : public Object {
3087 public: 3084 public:
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
5525 // the formal parameters given in param_names, and is invoked with 5522 // the formal parameters given in param_names, and is invoked with
5526 // the argument values given in param_values. 5523 // the argument values given in param_values.
5527 RawObject* Evaluate(const Class& method_cls, 5524 RawObject* Evaluate(const Class& method_cls,
5528 const String& expr, 5525 const String& expr,
5529 const Array& param_names, 5526 const Array& param_names,
5530 const Array& param_values) const; 5527 const Array& param_values) const;
5531 5528
5532 // Equivalent to invoking hashCode on this instance. 5529 // Equivalent to invoking hashCode on this instance.
5533 virtual RawObject* HashCode() const; 5530 virtual RawObject* HashCode() const;
5534 5531
5532 // Equivalent to invoking identityHashCode with this instance.
5533 RawObject* IdentityHashCode() const;
5534
5535 static intptr_t InstanceSize() { 5535 static intptr_t InstanceSize() {
5536 return RoundedAllocationSize(sizeof(RawInstance)); 5536 return RoundedAllocationSize(sizeof(RawInstance));
5537 } 5537 }
5538 5538
5539 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); 5539 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew);
5540 5540
5541 // Array/list element address computations. 5541 // Array/list element address computations.
5542 static intptr_t DataOffsetFor(intptr_t cid); 5542 static intptr_t DataOffsetFor(intptr_t cid);
5543 static intptr_t ElementSizeFor(intptr_t cid); 5543 static intptr_t ElementSizeFor(intptr_t cid);
5544 5544
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after
8333 static intptr_t function_type_arguments_offset() { 8333 static intptr_t function_type_arguments_offset() {
8334 return OFFSET_OF(RawClosure, function_type_arguments_); 8334 return OFFSET_OF(RawClosure, function_type_arguments_);
8335 } 8335 }
8336 8336
8337 RawFunction* function() const { return raw_ptr()->function_; } 8337 RawFunction* function() const { return raw_ptr()->function_; }
8338 static intptr_t function_offset() { return OFFSET_OF(RawClosure, function_); } 8338 static intptr_t function_offset() { return OFFSET_OF(RawClosure, function_); }
8339 8339
8340 RawContext* context() const { return raw_ptr()->context_; } 8340 RawContext* context() const { return raw_ptr()->context_; }
8341 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); } 8341 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); }
8342 8342
8343 RawSmi* hash() const { return raw_ptr()->hash_; }
8344 static intptr_t hash_offset() { return OFFSET_OF(RawClosure, hash_); }
8345
8343 static intptr_t InstanceSize() { 8346 static intptr_t InstanceSize() {
8344 return RoundedAllocationSize(sizeof(RawClosure)); 8347 return RoundedAllocationSize(sizeof(RawClosure));
8345 } 8348 }
8346 8349
8347 // Returns true if all elements are OK for canonicalization. 8350 // Returns true if all elements are OK for canonicalization.
8348 virtual bool CheckAndCanonicalizeFields(Thread* thread, 8351 virtual bool CheckAndCanonicalizeFields(Thread* thread,
8349 const char** error_str) const { 8352 const char** error_str) const {
8350 // None of the fields of a closure are instances. 8353 // None of the fields of a closure are instances.
8351 return true; 8354 return true;
8352 } 8355 }
8353 8356
8357 int64_t ComputeHash() const;
8358
8354 static RawClosure* New(const TypeArguments& instantiator_type_arguments, 8359 static RawClosure* New(const TypeArguments& instantiator_type_arguments,
8355 const TypeArguments& function_type_arguments, 8360 const TypeArguments& function_type_arguments,
8356 const Function& function, 8361 const Function& function,
8357 const Context& context, 8362 const Context& context,
8358 Heap::Space space = Heap::kNew); 8363 Heap::Space space = Heap::kNew);
8359 8364
8360 private: 8365 private:
8361 static RawClosure* New(); 8366 static RawClosure* New();
8362 8367
8363 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance); 8368 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
8913 8918
8914 inline void TypeArguments::SetHash(intptr_t value) const { 8919 inline void TypeArguments::SetHash(intptr_t value) const {
8915 // This is only safe because we create a new Smi, which does not cause 8920 // This is only safe because we create a new Smi, which does not cause
8916 // heap allocation. 8921 // heap allocation.
8917 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8922 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8918 } 8923 }
8919 8924
8920 } // namespace dart 8925 } // namespace dart
8921 8926
8922 #endif // RUNTIME_VM_OBJECT_H_ 8927 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698