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

Side by Side Diff: src/unique.h

Issue 552653003: [turbofan] Fix the node matchers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HYDROGEN_UNIQUE_H_ 5 #ifndef V8_HYDROGEN_UNIQUE_H_
6 #define V8_HYDROGEN_UNIQUE_H_ 6 #define V8_HYDROGEN_UNIQUE_H_
7 7
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 #include "src/string-stream.h" 10 #include "src/string-stream.h"
(...skipping 14 matching lines...) Expand all
25 // Creating a Unique<T> requires first dereferencing the handle to obtain 25 // Creating a Unique<T> requires first dereferencing the handle to obtain
26 // the address of the object, which is used as the hashcode and the basis for 26 // the address of the object, which is used as the hashcode and the basis for
27 // comparison. The object can be moved later by the GC, but comparison 27 // comparison. The object can be moved later by the GC, but comparison
28 // and hashing use the old address of the object, without dereferencing it. 28 // and hashing use the old address of the object, without dereferencing it.
29 // 29 //
30 // Careful! Comparison of two Uniques is only correct if both were created 30 // Careful! Comparison of two Uniques is only correct if both were created
31 // in the same "era" of GC or if at least one is a non-movable object. 31 // in the same "era" of GC or if at least one is a non-movable object.
32 template <typename T> 32 template <typename T>
33 class Unique { 33 class Unique {
34 public: 34 public:
35 Unique<T>() : raw_address_(NULL) {}
36
35 // TODO(titzer): make private and introduce a uniqueness scope. 37 // TODO(titzer): make private and introduce a uniqueness scope.
36 explicit Unique(Handle<T> handle) { 38 explicit Unique(Handle<T> handle) {
37 if (handle.is_null()) { 39 if (handle.is_null()) {
38 raw_address_ = NULL; 40 raw_address_ = NULL;
39 } else { 41 } else {
40 // This is a best-effort check to prevent comparing Unique<T>'s created 42 // This is a best-effort check to prevent comparing Unique<T>'s created
41 // in different GC eras; we require heap allocation to be disallowed at 43 // in different GC eras; we require heap allocation to be disallowed at
42 // creation time. 44 // creation time.
43 // NOTE: we currently consider maps to be non-movable, so no special 45 // NOTE: we currently consider maps to be non-movable, so no special
44 // assurance is required for creating a Unique<Map>. 46 // assurance is required for creating a Unique<Map>.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 115
114 static Unique<T> CreateImmovable(Handle<T> handle) { 116 static Unique<T> CreateImmovable(Handle<T> handle) {
115 return Unique<T>(reinterpret_cast<Address>(*handle), handle); 117 return Unique<T>(reinterpret_cast<Address>(*handle), handle);
116 } 118 }
117 119
118 friend class UniqueSet<T>; // Uses internal details for speed. 120 friend class UniqueSet<T>; // Uses internal details for speed.
119 template <class U> 121 template <class U>
120 friend class Unique; // For comparing raw_address values. 122 friend class Unique; // For comparing raw_address values.
121 123
122 protected: 124 protected:
123 Unique<T>() : raw_address_(NULL) { }
124
125 Address raw_address_; 125 Address raw_address_;
126 Handle<T> handle_; 126 Handle<T> handle_;
127 127
128 friend class SideEffectsTracker; 128 friend class SideEffectsTracker;
129 }; 129 };
130 130
131 131
132 template <typename T> 132 template <typename T>
133 class UniqueSet FINAL : public ZoneObject { 133 class UniqueSet FINAL : public ZoneObject {
134 public: 134 public:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 capacity_ = new_capacity; 339 capacity_ = new_capacity;
340 array_ = new_array; 340 array_ = new_array;
341 } 341 }
342 } 342 }
343 }; 343 };
344 344
345 } } // namespace v8::internal 345 } } // namespace v8::internal
346 346
347 #endif // V8_HYDROGEN_UNIQUE_H_ 347 #endif // V8_HYDROGEN_UNIQUE_H_
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/cctest/compiler/test-js-constant-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698