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

Side by Side Diff: src/lookup.cc

Issue 1675223002: Mark maps having a hidden prototype rather than maps of hidden prototypes. (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/ic/ic.cc ('k') | src/mips/builtins-mips.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(), receiver_); 125 PrototypeIterator iter(isolate(), Handle<JSGlobalProxy>::cast(receiver_));
126 if (iter.IsAtEnd()) return Handle<JSGlobalProxy>::cast(receiver_); 126 if (iter.IsAtEnd()) return Handle<JSGlobalProxy>::cast(receiver_);
127 return PrototypeIterator::GetCurrent<JSGlobalObject>(iter); 127 return PrototypeIterator::GetCurrent<JSGlobalObject>(iter);
128 } 128 }
129 return Handle<JSObject>::cast(receiver_); 129 return Handle<JSObject>::cast(receiver_);
130 } 130 }
131 131
132 132
133 bool LookupIterator::HasAccess() const { 133 bool LookupIterator::HasAccess() const {
134 DCHECK_EQ(ACCESS_CHECK, state_); 134 DCHECK_EQ(ACCESS_CHECK, state_);
135 return isolate_->MayAccess(handle(isolate_->context()), 135 return isolate_->MayAccess(handle(isolate_->context()),
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 bool LookupIterator::HolderIsReceiverOrHiddenPrototype() const { 392 bool LookupIterator::HolderIsReceiverOrHiddenPrototype() const {
393 DCHECK(has_property_ || state_ == INTERCEPTOR || state_ == JSPROXY); 393 DCHECK(has_property_ || state_ == INTERCEPTOR || state_ == JSPROXY);
394 // Optimization that only works if configuration_ is not mutable. 394 // Optimization that only works if configuration_ is not mutable.
395 if (!check_prototype_chain()) return true; 395 if (!check_prototype_chain()) return true;
396 DisallowHeapAllocation no_gc; 396 DisallowHeapAllocation no_gc;
397 if (!receiver_->IsJSReceiver()) return false; 397 if (!receiver_->IsJSReceiver()) return false;
398 JSReceiver* current = JSReceiver::cast(*receiver_); 398 JSReceiver* current = JSReceiver::cast(*receiver_);
399 JSReceiver* object = *holder_; 399 JSReceiver* object = *holder_;
400 if (current == object) return true; 400 if (current == object) return true;
401 if (!object->map()->is_hidden_prototype()) return false; 401 if (!current->map()->has_hidden_prototype()) return false;
402 // JSProxy do not occur as hidden prototypes. 402 // JSProxy do not occur as hidden prototypes.
403 if (current->IsJSProxy()) return false; 403 if (current->IsJSProxy()) return false;
404 PrototypeIterator iter(isolate(), current); 404 PrototypeIterator iter(isolate(), current,
405 while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { 405 PrototypeIterator::START_AT_PROTOTYPE,
406 PrototypeIterator::END_AT_NON_HIDDEN);
407 while (!iter.IsAtEnd()) {
406 if (iter.GetCurrent<JSReceiver>() == object) return true; 408 if (iter.GetCurrent<JSReceiver>() == object) return true;
407 iter.Advance(); 409 iter.Advance();
408 } 410 }
409 return false; 411 return false;
410 } 412 }
411 413
412 414
413 Handle<Object> LookupIterator::FetchValue() const { 415 Handle<Object> LookupIterator::FetchValue() const {
414 Object* result = NULL; 416 Object* result = NULL;
415 if (IsElement()) { 417 if (IsElement()) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 548 }
547 } 549 }
548 return interceptor_state_ == InterceptorState::kProcessNonMasking; 550 return interceptor_state_ == InterceptorState::kProcessNonMasking;
549 } 551 }
550 552
551 553
552 JSReceiver* LookupIterator::NextHolder(Map* map) { 554 JSReceiver* LookupIterator::NextHolder(Map* map) {
553 DisallowHeapAllocation no_gc; 555 DisallowHeapAllocation no_gc;
554 if (!map->prototype()->IsJSReceiver()) return NULL; 556 if (!map->prototype()->IsJSReceiver()) return NULL;
555 557
556 JSReceiver* next = JSReceiver::cast(map->prototype()); 558 DCHECK(!map->IsJSGlobalProxyMap() || map->has_hidden_prototype());
557 DCHECK(!next->map()->IsJSGlobalObjectMap() ||
558 next->map()->is_hidden_prototype());
559 559
560 if (!check_prototype_chain() && 560 if (!check_prototype_chain() &&
561 !(check_hidden() && next->map()->is_hidden_prototype()) && 561 !(check_hidden() && map->has_hidden_prototype()) &&
562 // Always lookup behind the JSGlobalProxy into the JSGlobalObject, even 562 // Always lookup behind the JSGlobalProxy into the JSGlobalObject, even
563 // when not checking other hidden prototypes. 563 // when not checking other hidden prototypes.
564 !map->IsJSGlobalProxyMap()) { 564 !map->IsJSGlobalProxyMap()) {
565 return NULL; 565 return NULL;
566 } 566 }
567 567
568 return next; 568 return JSReceiver::cast(map->prototype());
569 } 569 }
570 570
571 LookupIterator::State LookupIterator::NotFound(JSReceiver* const holder) const { 571 LookupIterator::State LookupIterator::NotFound(JSReceiver* const holder) const {
572 DCHECK(!IsElement()); 572 DCHECK(!IsElement());
573 if (!holder->IsJSTypedArray() || !name_->IsString()) return NOT_FOUND; 573 if (!holder->IsJSTypedArray() || !name_->IsString()) return NOT_FOUND;
574 574
575 Handle<String> name_string = Handle<String>::cast(name_); 575 Handle<String> name_string = Handle<String>::cast(name_);
576 if (name_string->length() == 0) return NOT_FOUND; 576 if (name_string->length() == 0) return NOT_FOUND;
577 577
578 return IsSpecialIndex(isolate_->unicode_cache(), *name_string) 578 return IsSpecialIndex(isolate_->unicode_cache(), *name_string)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // Fall through. 669 // Fall through.
670 default: 670 default:
671 return NOT_FOUND; 671 return NOT_FOUND;
672 } 672 }
673 UNREACHABLE(); 673 UNREACHABLE();
674 return state_; 674 return state_;
675 } 675 }
676 676
677 } // namespace internal 677 } // namespace internal
678 } // namespace v8 678 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698