| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PROTOTYPE_H_ | 5 #ifndef V8_PROTOTYPE_H_ |
| 6 #define V8_PROTOTYPE_H_ | 6 #define V8_PROTOTYPE_H_ |
| 7 | 7 |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class PrototypeIterator { | 26 class PrototypeIterator { |
| 27 public: | 27 public: |
| 28 enum WhereToEnd { END_AT_NULL, END_AT_NON_HIDDEN }; | 28 enum WhereToEnd { END_AT_NULL, END_AT_NON_HIDDEN }; |
| 29 | 29 |
| 30 const int kProxyPrototypeLimit = 100 * 1000; | 30 const int kProxyPrototypeLimit = 100 * 1000; |
| 31 | 31 |
| 32 PrototypeIterator(Isolate* isolate, Handle<JSReceiver> receiver, | 32 PrototypeIterator(Isolate* isolate, Handle<JSReceiver> receiver, |
| 33 WhereToStart where_to_start = kStartAtPrototype, | 33 WhereToStart where_to_start = kStartAtPrototype, |
| 34 WhereToEnd where_to_end = END_AT_NULL) | 34 WhereToEnd where_to_end = END_AT_NULL) |
| 35 : object_(NULL), | 35 : isolate_(isolate), |
| 36 object_(NULL), |
| 36 handle_(receiver), | 37 handle_(receiver), |
| 37 isolate_(isolate), | |
| 38 where_to_end_(where_to_end), | 38 where_to_end_(where_to_end), |
| 39 is_at_end_(false), | 39 is_at_end_(false), |
| 40 seen_proxies_(0) { | 40 seen_proxies_(0) { |
| 41 CHECK(!handle_.is_null()); | 41 CHECK(!handle_.is_null()); |
| 42 if (where_to_start == kStartAtPrototype) Advance(); | 42 if (where_to_start == kStartAtPrototype) Advance(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 PrototypeIterator(Isolate* isolate, JSReceiver* receiver, | 45 PrototypeIterator(Isolate* isolate, JSReceiver* receiver, |
| 46 WhereToStart where_to_start = kStartAtPrototype, | 46 WhereToStart where_to_start = kStartAtPrototype, |
| 47 WhereToEnd where_to_end = END_AT_NULL) | 47 WhereToEnd where_to_end = END_AT_NULL) |
| 48 : object_(receiver), | 48 : isolate_(isolate), |
| 49 isolate_(isolate), | 49 object_(receiver), |
| 50 where_to_end_(where_to_end), | 50 where_to_end_(where_to_end), |
| 51 is_at_end_(false), | 51 is_at_end_(false), |
| 52 seen_proxies_(0) { | 52 seen_proxies_(0) { |
| 53 if (where_to_start == kStartAtPrototype) Advance(); | 53 if (where_to_start == kStartAtPrototype) Advance(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 explicit PrototypeIterator(Map* receiver_map) | 56 explicit PrototypeIterator(Map* receiver_map) |
| 57 : object_(receiver_map->prototype()), | 57 : isolate_(receiver_map->GetIsolate()), |
| 58 isolate_(receiver_map->GetIsolate()), | 58 object_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype()), |
| 59 where_to_end_(END_AT_NULL), | 59 where_to_end_(END_AT_NULL), |
| 60 is_at_end_(object_->IsNull(isolate_)), | 60 is_at_end_(object_->IsNull(isolate_)), |
| 61 seen_proxies_(0) {} | 61 seen_proxies_(0) {} |
| 62 | 62 |
| 63 explicit PrototypeIterator(Handle<Map> receiver_map) | 63 explicit PrototypeIterator(Handle<Map> receiver_map) |
| 64 : object_(NULL), | 64 : isolate_(receiver_map->GetIsolate()), |
| 65 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), | 65 object_(NULL), |
| 66 isolate_(receiver_map->GetIsolate()), | 66 handle_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype(), |
| 67 isolate_), |
| 67 where_to_end_(END_AT_NULL), | 68 where_to_end_(END_AT_NULL), |
| 68 is_at_end_(handle_->IsNull(isolate_)), | 69 is_at_end_(handle_->IsNull(isolate_)), |
| 69 seen_proxies_(0) {} | 70 seen_proxies_(0) {} |
| 70 | 71 |
| 71 ~PrototypeIterator() {} | 72 ~PrototypeIterator() {} |
| 72 | 73 |
| 73 bool HasAccess() const { | 74 bool HasAccess() const { |
| 74 // We can only perform access check in the handlified version of the | 75 // We can only perform access check in the handlified version of the |
| 75 // PrototypeIterator. | 76 // PrototypeIterator. |
| 76 DCHECK(!handle_.is_null()); | 77 DCHECK(!handle_.is_null()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 JSProxy::GetPrototype(Handle<JSProxy>::cast(handle_)); | 155 JSProxy::GetPrototype(Handle<JSProxy>::cast(handle_)); |
| 155 if (!proto.ToHandle(&handle_)) return false; | 156 if (!proto.ToHandle(&handle_)) return false; |
| 156 is_at_end_ = | 157 is_at_end_ = |
| 157 where_to_end_ == END_AT_NON_HIDDEN || handle_->IsNull(isolate_); | 158 where_to_end_ == END_AT_NON_HIDDEN || handle_->IsNull(isolate_); |
| 158 return true; | 159 return true; |
| 159 } | 160 } |
| 160 | 161 |
| 161 bool IsAtEnd() const { return is_at_end_; } | 162 bool IsAtEnd() const { return is_at_end_; } |
| 162 | 163 |
| 163 private: | 164 private: |
| 165 Isolate* isolate_; |
| 164 Object* object_; | 166 Object* object_; |
| 165 Handle<Object> handle_; | 167 Handle<Object> handle_; |
| 166 Isolate* isolate_; | |
| 167 WhereToEnd where_to_end_; | 168 WhereToEnd where_to_end_; |
| 168 bool is_at_end_; | 169 bool is_at_end_; |
| 169 int seen_proxies_; | 170 int seen_proxies_; |
| 170 | 171 |
| 171 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); | 172 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 | 175 |
| 175 } // namespace internal | 176 } // namespace internal |
| 176 | 177 |
| 177 } // namespace v8 | 178 } // namespace v8 |
| 178 | 179 |
| 179 #endif // V8_PROTOTYPE_H_ | 180 #endif // V8_PROTOTYPE_H_ |
| OLD | NEW |