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

Unified Diff: src/unique.h

Issue 24350014: Use Unique<Object> in HConstant and remove UniqueValueId. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/unique.h
diff --git a/src/unique.h b/src/unique.h
index 68166541bce4ff796eb49eb788614def857c4457..fdb7016d799376f5dd390a1a2a4ca5f6f6ce768f 100644
--- a/src/unique.h
+++ b/src/unique.h
@@ -54,7 +54,7 @@ class UniqueSet;
template <typename T>
class Unique V8_FINAL {
public:
- // TODO(titzer): make private and introduce a factory.
+ // TODO(titzer): make private and introduce a uniqueness scope.
explicit Unique(Handle<T> handle) {
if (handle.is_null()) {
raw_address_ = NULL;
@@ -111,8 +111,11 @@ class Unique V8_FINAL {
return raw_address_ == NULL;
}
- // Extract the handle from this Unique in order to dereference it.
- // WARNING: Only do this if you have access to the heap.
Toon Verwaest 2013/09/24 09:17:54 Any reason you removed this comment?
+ inline bool IsKnownGlobal(void* global) const {
+ ASSERT(IsInitialized());
+ return raw_address_ == reinterpret_cast<Address>(global);
+ }
+
inline Handle<T> handle() const {
return handle_;
}
@@ -123,7 +126,11 @@ class Unique V8_FINAL {
// TODO(titzer): this is a hack to migrate to Unique<T> incrementally.
static Unique<T> CreateUninitialized(Handle<T> handle) {
- return Unique<T>(static_cast<Address>(NULL), handle);
+ return Unique<T>(reinterpret_cast<Address>(NULL), handle);
+ }
+
+ static Unique<T> CreateImmovable(Handle<T> handle) {
+ return Unique<T>(reinterpret_cast<Address>(*handle), handle);
}
friend class UniqueSet<T>; // Uses internal details for speed.
@@ -171,9 +178,10 @@ class UniqueSet V8_FINAL : public ZoneObject {
return true;
}
+ // Check whether this set contains the given element. O(|this|)
+ // TODO(titzer): use binary search for large sets to make this O(log|this|)
template <typename U>
bool Contains(Unique<U> elem) const {
- // TODO(titzer): use binary search for larger sets.
for (int i = 0; i < size_; i++) {
if (this->array_[i] == elem) return true;
}
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698