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

Side by Side Diff: src/lookup.cc

Issue 1702443002: [runtime] Minor tweaks to LookupIterator for performance (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 10 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
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('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/lookup.h" 5 #include "src/lookup.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/deoptimizer.h" 8 #include "src/deoptimizer.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 116
117 Handle<Map> LookupIterator::GetReceiverMap() const { 117 Handle<Map> LookupIterator::GetReceiverMap() const {
118 if (receiver_->IsNumber()) return factory()->heap_number_map(); 118 if (receiver_->IsNumber()) return factory()->heap_number_map();
119 return handle(Handle<HeapObject>::cast(receiver_)->map(), isolate_); 119 return handle(Handle<HeapObject>::cast(receiver_)->map(), isolate_);
120 } 120 }
121 121
122 122
123 Handle<JSObject> LookupIterator::GetStoreTarget() const { 123 Handle<JSObject> LookupIterator::GetStoreTarget() const {
124 if (receiver_->IsJSGlobalProxy()) { 124 if (receiver_->IsJSGlobalProxy()) {
125 PrototypeIterator iter(isolate(), Handle<JSGlobalProxy>::cast(receiver_)); 125 Object* prototype = JSGlobalProxy::cast(*receiver_)->map()->prototype();
126 if (iter.IsAtEnd()) return Handle<JSGlobalProxy>::cast(receiver_); 126 if (!prototype->IsNull()) return handle(JSGlobalObject::cast(prototype));
Camillo Bruni 2016/02/16 08:58:39 handle(JSGlobalObject::cast(prototype), isolate_)
127 return PrototypeIterator::GetCurrent<JSGlobalObject>(iter);
128 } 127 }
129 return Handle<JSObject>::cast(receiver_); 128 return Handle<JSObject>::cast(receiver_);
130 } 129 }
131 130
132 131
133 bool LookupIterator::HasAccess() const { 132 bool LookupIterator::HasAccess() const {
134 DCHECK_EQ(ACCESS_CHECK, state_); 133 DCHECK_EQ(ACCESS_CHECK, state_);
135 return isolate_->MayAccess(handle(isolate_->context()), 134 return isolate_->MayAccess(handle(isolate_->context()),
136 GetHolder<JSObject>()); 135 GetHolder<JSObject>());
137 } 136 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 ReloadPropertyInformation(); 224 ReloadPropertyInformation();
226 WriteDataValue(value); 225 WriteDataValue(value);
227 226
228 #if VERIFY_HEAP 227 #if VERIFY_HEAP
229 if (FLAG_verify_heap) { 228 if (FLAG_verify_heap) {
230 holder->JSObjectVerify(); 229 holder->JSObjectVerify();
231 } 230 }
232 #endif 231 #endif
233 } 232 }
234 233
235 234 // Can only be called when the receiver is a JSObject. JSProxy has to be handled
235 // via a trap. Adding properties to primitive values is not observable.
236 void LookupIterator::PrepareTransitionToDataProperty( 236 void LookupIterator::PrepareTransitionToDataProperty(
237 Handle<Object> value, PropertyAttributes attributes, 237 Handle<JSObject> receiver, Handle<Object> value,
238 Object::StoreFromKeyed store_mode) { 238 PropertyAttributes attributes, Object::StoreFromKeyed store_mode) {
239 DCHECK(receiver.is_identical_to(GetStoreTarget()));
239 if (state_ == TRANSITION) return; 240 if (state_ == TRANSITION) return;
240 DCHECK(state_ != LookupIterator::ACCESSOR || 241 DCHECK(state_ != LookupIterator::ACCESSOR ||
241 (GetAccessors()->IsAccessorInfo() && 242 (GetAccessors()->IsAccessorInfo() &&
242 AccessorInfo::cast(*GetAccessors())->is_special_data_property())); 243 AccessorInfo::cast(*GetAccessors())->is_special_data_property()));
243 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); 244 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_);
244 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); 245 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype());
245 // Can only be called when the receiver is a JSObject. JSProxy has to be
246 // handled via a trap. Adding properties to primitive values is not
247 // observable.
248 Handle<JSObject> receiver = GetStoreTarget();
249
250 if (!isolate()->IsInternallyUsedPropertyName(name()) &&
251 !receiver->map()->is_extensible()) {
252 return;
253 }
254 246
255 auto transition = Map::TransitionToDataProperty( 247 auto transition = Map::TransitionToDataProperty(
256 handle(receiver->map(), isolate_), name_, value, attributes, store_mode); 248 handle(receiver->map(), isolate_), name_, value, attributes, store_mode);
257 state_ = TRANSITION; 249 state_ = TRANSITION;
258 transition_ = transition; 250 transition_ = transition;
259 251
260 if (receiver->IsJSGlobalObject()) { 252 if (receiver->IsJSGlobalObject()) {
261 // Install a property cell. 253 // Install a property cell.
262 InternalizeName(); 254 InternalizeName();
263 auto cell = JSGlobalObject::EnsurePropertyCell( 255 auto cell = JSGlobalObject::EnsurePropertyCell(
264 Handle<JSGlobalObject>::cast(receiver), name()); 256 Handle<JSGlobalObject>::cast(receiver), name());
265 DCHECK(cell->value()->IsTheHole()); 257 DCHECK(cell->value()->IsTheHole());
266 transition_ = cell; 258 transition_ = cell;
267 } else if (!transition->is_dictionary_map()) { 259 } else if (!transition->is_dictionary_map()) {
268 property_details_ = transition->GetLastDescriptorDetails(); 260 property_details_ = transition->GetLastDescriptorDetails();
269 has_property_ = true; 261 has_property_ = true;
270 } 262 }
271 } 263 }
272 264
273 265 void LookupIterator::ApplyTransitionToDataProperty(Handle<JSObject> receiver) {
274 void LookupIterator::ApplyTransitionToDataProperty() {
275 DCHECK_EQ(TRANSITION, state_); 266 DCHECK_EQ(TRANSITION, state_);
276 267
277 Handle<JSObject> receiver = GetStoreTarget(); 268 DCHECK(receiver.is_identical_to(GetStoreTarget()));
269
278 if (receiver->IsJSGlobalObject()) return; 270 if (receiver->IsJSGlobalObject()) return;
279 holder_ = receiver; 271 holder_ = receiver;
280 Handle<Map> transition = transition_map(); 272 Handle<Map> transition = transition_map();
281 bool simple_transition = transition->GetBackPointer() == receiver->map(); 273 bool simple_transition = transition->GetBackPointer() == receiver->map();
282 holder_map_ = transition; 274 holder_map_ = transition;
283 JSObject::MigrateToMap(receiver, holder_map_); 275 JSObject::MigrateToMap(receiver, holder_map_);
284 276
285 if (simple_transition) { 277 if (simple_transition) {
286 int number = transition->LastAdded(); 278 int number = transition->LastAdded();
287 number_ = static_cast<uint32_t>(number); 279 number_ = static_cast<uint32_t>(number);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // Fall through. 685 // Fall through.
694 default: 686 default:
695 return NOT_FOUND; 687 return NOT_FOUND;
696 } 688 }
697 UNREACHABLE(); 689 UNREACHABLE();
698 return state_; 690 return state_;
699 } 691 }
700 692
701 } // namespace internal 693 } // namespace internal
702 } // namespace v8 694 } // namespace v8
OLDNEW
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698