| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 : isolate_(isolate), | 48 : isolate_(isolate), |
| 49 object_(receiver), | 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 WhereToEnd where_to_end = END_AT_NULL) |
| 57 : isolate_(receiver_map->GetIsolate()), | 58 : isolate_(receiver_map->GetIsolate()), |
| 58 object_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype()), | 59 object_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype()), |
| 59 where_to_end_(END_AT_NULL), | 60 where_to_end_(where_to_end), |
| 60 is_at_end_(object_->IsNull(isolate_)), | 61 is_at_end_(object_->IsNull(isolate_)), |
| 61 seen_proxies_(0) {} | 62 seen_proxies_(0) { |
| 63 if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) { |
| 64 DCHECK(object_->IsJSReceiver()); |
| 65 Map* map = JSReceiver::cast(object_)->map(); |
| 66 is_at_end_ = !map->has_hidden_prototype(); |
| 67 } |
| 68 } |
| 62 | 69 |
| 63 explicit PrototypeIterator(Handle<Map> receiver_map) | 70 explicit PrototypeIterator(Handle<Map> receiver_map, |
| 71 WhereToEnd where_to_end = END_AT_NULL) |
| 64 : isolate_(receiver_map->GetIsolate()), | 72 : isolate_(receiver_map->GetIsolate()), |
| 65 object_(NULL), | 73 object_(NULL), |
| 66 handle_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype(), | 74 handle_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype(), |
| 67 isolate_), | 75 isolate_), |
| 68 where_to_end_(END_AT_NULL), | 76 where_to_end_(where_to_end), |
| 69 is_at_end_(handle_->IsNull(isolate_)), | 77 is_at_end_(handle_->IsNull(isolate_)), |
| 70 seen_proxies_(0) {} | 78 seen_proxies_(0) { |
| 79 if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) { |
| 80 DCHECK(handle_->IsJSReceiver()); |
| 81 Map* map = JSReceiver::cast(*handle_)->map(); |
| 82 is_at_end_ = !map->has_hidden_prototype(); |
| 83 } |
| 84 } |
| 71 | 85 |
| 72 ~PrototypeIterator() {} | 86 ~PrototypeIterator() {} |
| 73 | 87 |
| 74 bool HasAccess() const { | 88 bool HasAccess() const { |
| 75 // We can only perform access check in the handlified version of the | 89 // We can only perform access check in the handlified version of the |
| 76 // PrototypeIterator. | 90 // PrototypeIterator. |
| 77 DCHECK(!handle_.is_null()); | 91 DCHECK(!handle_.is_null()); |
| 78 if (handle_->IsAccessCheckNeeded()) { | 92 if (handle_->IsAccessCheckNeeded()) { |
| 79 return isolate_->MayAccess(handle(isolate_->context()), | 93 return isolate_->MayAccess(handle(isolate_->context()), |
| 80 Handle<JSObject>::cast(handle_)); | 94 Handle<JSObject>::cast(handle_)); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 184 |
| 171 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); | 185 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); |
| 172 }; | 186 }; |
| 173 | 187 |
| 174 | 188 |
| 175 } // namespace internal | 189 } // namespace internal |
| 176 | 190 |
| 177 } // namespace v8 | 191 } // namespace v8 |
| 178 | 192 |
| 179 #endif // V8_PROTOTYPE_H_ | 193 #endif // V8_PROTOTYPE_H_ |
| OLD | NEW |