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

Side by Side Diff: src/lookup.cc

Issue 437513002: Inline LookupInHolder and NextHolder (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Don't recreate a handle for the map if it didn't change Created 6 years, 4 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
« no previous file with comments | « src/lookup.h ('k') | src/lookup-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/lookup.h" 8 #include "src/lookup.h"
9 #include "src/lookup-inl.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 14
14 void LookupIterator::Next() { 15 void LookupIterator::Next() {
16 DisallowHeapAllocation no_gc;
15 has_property_ = false; 17 has_property_ = false;
16 do { 18
17 state_ = LookupInHolder(); 19 JSReceiver* holder = NULL;
18 } while (!IsFound() && NextHolder()); 20 Map* map = *holder_map_;
21
22 // Perform lookup on current holder.
23 state_ = LookupInHolder(map);
24
25 // Continue lookup if lookup on current holder failed.
26 while (!IsFound()) {
27 JSReceiver* maybe_holder = NextHolder(map);
28 if (maybe_holder == NULL) break;
29 holder = maybe_holder;
30 map = holder->map();
31 state_ = LookupInHolder(map);
32 }
33
34 // Either was found in the receiver, or the receiver has no prototype.
35 if (holder == NULL) return;
36
37 maybe_holder_ = handle(holder);
38 holder_map_ = handle(map);
19 } 39 }
20 40
21 41
22 Handle<JSReceiver> LookupIterator::GetRoot() const { 42 Handle<JSReceiver> LookupIterator::GetRoot() const {
23 Handle<Object> receiver = GetReceiver(); 43 Handle<Object> receiver = GetReceiver();
24 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); 44 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
25 Handle<Object> root = 45 Handle<Object> root =
26 handle(receiver->GetRootMap(isolate_)->prototype(), isolate_); 46 handle(receiver->GetRootMap(isolate_)->prototype(), isolate_);
27 CHECK(!root->IsNull()); 47 CHECK(!root->IsNull());
28 return Handle<JSReceiver>::cast(root); 48 return Handle<JSReceiver>::cast(root);
29 } 49 }
30 50
31 51
32 Handle<Map> LookupIterator::GetReceiverMap() const { 52 Handle<Map> LookupIterator::GetReceiverMap() const {
33 Handle<Object> receiver = GetReceiver(); 53 Handle<Object> receiver = GetReceiver();
34 if (receiver->IsNumber()) return isolate_->factory()->heap_number_map(); 54 if (receiver->IsNumber()) return isolate_->factory()->heap_number_map();
35 return handle(Handle<HeapObject>::cast(receiver)->map()); 55 return handle(Handle<HeapObject>::cast(receiver)->map());
36 } 56 }
37 57
38 58
39 bool LookupIterator::NextHolder() {
40 if (holder_map_->prototype()->IsNull()) return false;
41
42 Handle<JSReceiver> next(JSReceiver::cast(holder_map_->prototype()));
43
44 if (!check_derived() &&
45 !(check_hidden() &&
46 // TODO(verwaest): Check if this is actually necessary currently. If it
47 // is, this should be handled by setting is_hidden_prototype on the
48 // global object behind the proxy.
49 (holder_map_->IsJSGlobalProxyMap() ||
50 next->map()->is_hidden_prototype()))) {
51 return false;
52 }
53
54 holder_map_ = handle(next->map());
55 maybe_holder_ = next;
56 return true;
57 }
58
59
60 LookupIterator::State LookupIterator::LookupInHolder() {
61 switch (state_) {
62 case NOT_FOUND:
63 if (holder_map_->IsJSProxyMap()) {
64 return JSPROXY;
65 }
66 if (check_access_check() && holder_map_->is_access_check_needed()) {
67 return ACCESS_CHECK;
68 }
69 // Fall through.
70 case ACCESS_CHECK:
71 if (check_interceptor() && holder_map_->has_named_interceptor()) {
72 return INTERCEPTOR;
73 }
74 // Fall through.
75 case INTERCEPTOR:
76 if (holder_map_->is_dictionary_map()) {
77 property_encoding_ = DICTIONARY;
78 } else {
79 DescriptorArray* descriptors = holder_map_->instance_descriptors();
80 number_ = descriptors->SearchWithCache(*name_, *holder_map_);
81 if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
82 property_encoding_ = DESCRIPTOR;
83 }
84 return PROPERTY;
85 case PROPERTY:
86 return NOT_FOUND;
87 case JSPROXY:
88 UNREACHABLE();
89 }
90 UNREACHABLE();
91 return state_;
92 }
93
94
95 bool LookupIterator::IsBootstrapping() const { 59 bool LookupIterator::IsBootstrapping() const {
96 return isolate_->bootstrapper()->IsActive(); 60 return isolate_->bootstrapper()->IsActive();
97 } 61 }
98 62
99 63
100 bool LookupIterator::HasAccess(v8::AccessType access_type) const { 64 bool LookupIterator::HasAccess(v8::AccessType access_type) const {
101 ASSERT_EQ(ACCESS_CHECK, state_); 65 ASSERT_EQ(ACCESS_CHECK, state_);
102 ASSERT(is_guaranteed_to_have_holder()); 66 ASSERT(is_guaranteed_to_have_holder());
103 return isolate_->MayNamedAccess(GetHolder<JSObject>(), name_, access_type); 67 return isolate_->MayNamedAccess(GetHolder<JSObject>(), name_, access_type);
104 } 68 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 145 }
182 146
183 maybe_holder_ = receiver; 147 maybe_holder_ = receiver;
184 holder_map_ = Map::TransitionToDataProperty(handle(receiver->map()), name_, 148 holder_map_ = Map::TransitionToDataProperty(handle(receiver->map()), name_,
185 value, attributes, store_mode); 149 value, attributes, store_mode);
186 JSObject::MigrateToMap(receiver, holder_map_); 150 JSObject::MigrateToMap(receiver, holder_map_);
187 151
188 // Reload the information. 152 // Reload the information.
189 state_ = NOT_FOUND; 153 state_ = NOT_FOUND;
190 configuration_ = CHECK_OWN_REAL; 154 configuration_ = CHECK_OWN_REAL;
191 state_ = LookupInHolder(); 155 state_ = LookupInHolder(*holder_map_);
192 ASSERT(IsFound()); 156 ASSERT(IsFound());
193 HasProperty(); 157 HasProperty();
194 } 158 }
195 159
196 160
197 bool LookupIterator::HolderIsReceiver() const { 161 bool LookupIterator::HolderIsReceiver() const {
198 ASSERT(has_property_ || state_ == INTERCEPTOR || state_ == JSPROXY); 162 ASSERT(has_property_ || state_ == INTERCEPTOR || state_ == JSPROXY);
199 DisallowHeapAllocation no_gc; 163 DisallowHeapAllocation no_gc;
200 Handle<Object> receiver = GetReceiver(); 164 Handle<Object> receiver = GetReceiver();
201 if (!receiver->IsJSReceiver()) return false; 165 if (!receiver->IsJSReceiver()) return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 ASSERT_EQ(v8::internal::CONSTANT, property_details_.type()); 237 ASSERT_EQ(v8::internal::CONSTANT, property_details_.type());
274 } 238 }
275 } 239 }
276 240
277 241
278 void LookupIterator::InternalizeName() { 242 void LookupIterator::InternalizeName() {
279 if (name_->IsUniqueName()) return; 243 if (name_->IsUniqueName()) return;
280 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); 244 name_ = factory()->InternalizeString(Handle<String>::cast(name_));
281 } 245 }
282 } } // namespace v8::internal 246 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup.h ('k') | src/lookup-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698