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

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: Addressed comment 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()) {
127 return PrototypeIterator::GetCurrent<JSGlobalObject>(iter); 127 return handle(JSGlobalObject::cast(prototype), isolate_);
128 }
128 } 129 }
129 return Handle<JSObject>::cast(receiver_); 130 return Handle<JSObject>::cast(receiver_);
130 } 131 }
131 132
132 133
133 bool LookupIterator::HasAccess() const { 134 bool LookupIterator::HasAccess() const {
134 DCHECK_EQ(ACCESS_CHECK, state_); 135 DCHECK_EQ(ACCESS_CHECK, state_);
135 return isolate_->MayAccess(handle(isolate_->context()), 136 return isolate_->MayAccess(handle(isolate_->context()),
136 GetHolder<JSObject>()); 137 GetHolder<JSObject>());
137 } 138 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 ReloadPropertyInformation(); 226 ReloadPropertyInformation();
226 WriteDataValue(value); 227 WriteDataValue(value);
227 228
228 #if VERIFY_HEAP 229 #if VERIFY_HEAP
229 if (FLAG_verify_heap) { 230 if (FLAG_verify_heap) {
230 holder->JSObjectVerify(); 231 holder->JSObjectVerify();
231 } 232 }
232 #endif 233 #endif
233 } 234 }
234 235
235 236 // Can only be called when the receiver is a JSObject. JSProxy has to be handled
237 // via a trap. Adding properties to primitive values is not observable.
236 void LookupIterator::PrepareTransitionToDataProperty( 238 void LookupIterator::PrepareTransitionToDataProperty(
237 Handle<Object> value, PropertyAttributes attributes, 239 Handle<JSObject> receiver, Handle<Object> value,
238 Object::StoreFromKeyed store_mode) { 240 PropertyAttributes attributes, Object::StoreFromKeyed store_mode) {
241 DCHECK(receiver.is_identical_to(GetStoreTarget()));
239 if (state_ == TRANSITION) return; 242 if (state_ == TRANSITION) return;
240 DCHECK(state_ != LookupIterator::ACCESSOR || 243 DCHECK(state_ != LookupIterator::ACCESSOR ||
241 (GetAccessors()->IsAccessorInfo() && 244 (GetAccessors()->IsAccessorInfo() &&
242 AccessorInfo::cast(*GetAccessors())->is_special_data_property())); 245 AccessorInfo::cast(*GetAccessors())->is_special_data_property()));
243 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); 246 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_);
244 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); 247 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 248
255 auto transition = Map::TransitionToDataProperty( 249 auto transition = Map::TransitionToDataProperty(
256 handle(receiver->map(), isolate_), name_, value, attributes, store_mode); 250 handle(receiver->map(), isolate_), name_, value, attributes, store_mode);
257 state_ = TRANSITION; 251 state_ = TRANSITION;
258 transition_ = transition; 252 transition_ = transition;
259 253
260 if (receiver->IsJSGlobalObject()) { 254 if (receiver->IsJSGlobalObject()) {
261 // Install a property cell. 255 // Install a property cell.
262 InternalizeName(); 256 InternalizeName();
263 auto cell = JSGlobalObject::EnsurePropertyCell( 257 auto cell = JSGlobalObject::EnsurePropertyCell(
264 Handle<JSGlobalObject>::cast(receiver), name()); 258 Handle<JSGlobalObject>::cast(receiver), name());
265 DCHECK(cell->value()->IsTheHole()); 259 DCHECK(cell->value()->IsTheHole());
266 transition_ = cell; 260 transition_ = cell;
267 } else if (!transition->is_dictionary_map()) { 261 } else if (!transition->is_dictionary_map()) {
268 property_details_ = transition->GetLastDescriptorDetails(); 262 property_details_ = transition->GetLastDescriptorDetails();
269 has_property_ = true; 263 has_property_ = true;
270 } 264 }
271 } 265 }
272 266
273 267 void LookupIterator::ApplyTransitionToDataProperty(Handle<JSObject> receiver) {
274 void LookupIterator::ApplyTransitionToDataProperty() {
275 DCHECK_EQ(TRANSITION, state_); 268 DCHECK_EQ(TRANSITION, state_);
276 269
277 Handle<JSObject> receiver = GetStoreTarget(); 270 DCHECK(receiver.is_identical_to(GetStoreTarget()));
271
278 if (receiver->IsJSGlobalObject()) return; 272 if (receiver->IsJSGlobalObject()) return;
279 holder_ = receiver; 273 holder_ = receiver;
280 Handle<Map> transition = transition_map(); 274 Handle<Map> transition = transition_map();
281 bool simple_transition = transition->GetBackPointer() == receiver->map(); 275 bool simple_transition = transition->GetBackPointer() == receiver->map();
282 holder_map_ = transition; 276 holder_map_ = transition;
283 JSObject::MigrateToMap(receiver, holder_map_); 277 JSObject::MigrateToMap(receiver, holder_map_);
284 278
285 if (simple_transition) { 279 if (simple_transition) {
286 int number = transition->LastAdded(); 280 int number = transition->LastAdded();
287 number_ = static_cast<uint32_t>(number); 281 number_ = static_cast<uint32_t>(number);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // Fall through. 687 // Fall through.
694 default: 688 default:
695 return NOT_FOUND; 689 return NOT_FOUND;
696 } 690 }
697 UNREACHABLE(); 691 UNREACHABLE();
698 return state_; 692 return state_;
699 } 693 }
700 694
701 } // namespace internal 695 } // namespace internal
702 } // namespace v8 696 } // 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