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

Side by Side Diff: src/prototype.h

Issue 2043183003: Replace all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: simplifying checks Created 4 years, 6 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 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 where_to_end_(where_to_end), 52 where_to_end_(where_to_end),
53 is_at_end_(false), 53 is_at_end_(false),
54 seen_proxies_(0) { 54 seen_proxies_(0) {
55 if (where_to_start == START_AT_PROTOTYPE) Advance(); 55 if (where_to_start == START_AT_PROTOTYPE) Advance();
56 } 56 }
57 57
58 explicit PrototypeIterator(Map* receiver_map) 58 explicit PrototypeIterator(Map* receiver_map)
59 : object_(receiver_map->prototype()), 59 : object_(receiver_map->prototype()),
60 isolate_(receiver_map->GetIsolate()), 60 isolate_(receiver_map->GetIsolate()),
61 where_to_end_(END_AT_NULL), 61 where_to_end_(END_AT_NULL),
62 is_at_end_(object_->IsNull()) {} 62 is_at_end_(object_->IsNull(isolate_)) {}
63 63
64 explicit PrototypeIterator(Handle<Map> receiver_map) 64 explicit PrototypeIterator(Handle<Map> receiver_map)
65 : object_(NULL), 65 : object_(NULL),
66 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), 66 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())),
67 isolate_(receiver_map->GetIsolate()), 67 isolate_(receiver_map->GetIsolate()),
68 where_to_end_(END_AT_NULL), 68 where_to_end_(END_AT_NULL),
69 is_at_end_(handle_->IsNull()) {} 69 is_at_end_(handle_->IsNull(isolate_)) {}
70 70
71 ~PrototypeIterator() {} 71 ~PrototypeIterator() {}
72 72
73 bool HasAccess() const { 73 bool HasAccess() const {
74 // We can only perform access check in the handlified version of the 74 // We can only perform access check in the handlified version of the
75 // PrototypeIterator. 75 // PrototypeIterator.
76 DCHECK(!handle_.is_null()); 76 DCHECK(!handle_.is_null());
77 if (handle_->IsAccessCheckNeeded()) { 77 if (handle_->IsAccessCheckNeeded()) {
78 return isolate_->MayAccess(handle(isolate_->context()), 78 return isolate_->MayAccess(handle(isolate_->context()),
79 Handle<JSObject>::cast(handle_)); 79 Handle<JSObject>::cast(handle_));
(...skipping 27 matching lines...) Expand all
107 AdvanceIgnoringProxies(); 107 AdvanceIgnoringProxies();
108 } 108 }
109 109
110 void AdvanceIgnoringProxies() { 110 void AdvanceIgnoringProxies() {
111 Object* object = handle_.is_null() ? object_ : *handle_; 111 Object* object = handle_.is_null() ? object_ : *handle_;
112 Map* map = HeapObject::cast(object)->map(); 112 Map* map = HeapObject::cast(object)->map();
113 113
114 Object* prototype = map->prototype(); 114 Object* prototype = map->prototype();
115 is_at_end_ = where_to_end_ == END_AT_NON_HIDDEN 115 is_at_end_ = where_to_end_ == END_AT_NON_HIDDEN
116 ? !map->has_hidden_prototype() 116 ? !map->has_hidden_prototype()
117 : prototype->IsNull(); 117 : prototype->IsNull(isolate_);
118 118
119 if (handle_.is_null()) { 119 if (handle_.is_null()) {
120 object_ = prototype; 120 object_ = prototype;
121 } else { 121 } else {
122 handle_ = handle(prototype, isolate_); 122 handle_ = handle(prototype, isolate_);
123 } 123 }
124 } 124 }
125 125
126 // Returns false iff a call to JSProxy::GetPrototype throws. 126 // Returns false iff a call to JSProxy::GetPrototype throws.
127 // TODO(neis): This should probably replace Advance(). 127 // TODO(neis): This should probably replace Advance().
(...skipping 18 matching lines...) Expand all
146 // we visit to an arbitrarily chosen large number. 146 // we visit to an arbitrarily chosen large number.
147 seen_proxies_++; 147 seen_proxies_++;
148 if (seen_proxies_ > kProxyPrototypeLimit) { 148 if (seen_proxies_ > kProxyPrototypeLimit) {
149 isolate_->Throw( 149 isolate_->Throw(
150 *isolate_->factory()->NewRangeError(MessageTemplate::kStackOverflow)); 150 *isolate_->factory()->NewRangeError(MessageTemplate::kStackOverflow));
151 return false; 151 return false;
152 } 152 }
153 MaybeHandle<Object> proto = 153 MaybeHandle<Object> proto =
154 JSProxy::GetPrototype(Handle<JSProxy>::cast(handle_)); 154 JSProxy::GetPrototype(Handle<JSProxy>::cast(handle_));
155 if (!proto.ToHandle(&handle_)) return false; 155 if (!proto.ToHandle(&handle_)) return false;
156 is_at_end_ = where_to_end_ == END_AT_NON_HIDDEN || handle_->IsNull(); 156 is_at_end_ =
157 where_to_end_ == END_AT_NON_HIDDEN || handle_->IsNull(isolate_);
157 return true; 158 return true;
158 } 159 }
159 160
160 bool IsAtEnd() const { return is_at_end_; } 161 bool IsAtEnd() const { return is_at_end_; }
161 162
162 private: 163 private:
163 Object* object_; 164 Object* object_;
164 Handle<Object> handle_; 165 Handle<Object> handle_;
165 Isolate* isolate_; 166 Isolate* isolate_;
166 WhereToEnd where_to_end_; 167 WhereToEnd where_to_end_;
167 bool is_at_end_; 168 bool is_at_end_;
168 int seen_proxies_; 169 int seen_proxies_;
169 170
170 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); 171 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator);
171 }; 172 };
172 173
173 174
174 } // namespace internal 175 } // namespace internal
175 176
176 } // namespace v8 177 } // namespace v8
177 178
178 #endif // V8_PROTOTYPE_H_ 179 #endif // V8_PROTOTYPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698