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

Unified Diff: src/lookup.cc

Issue 1612323003: Introduce {FAST,SLOW}_STRING_WRAPPER_ELEMENTS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: one more DCHECK fix Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/key-accumulator.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index c19e25c024c91541dddc7bb7d506f965e97c50dc..7d74ffbf570ad65088cee39decb7f9753f682188 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -398,19 +398,17 @@ bool LookupIterator::InternalHolderIsReceiverOrHiddenPrototype() const {
if (!check_prototype_chain()) return true;
DisallowHeapAllocation no_gc;
if (!receiver_->IsJSReceiver()) return false;
- Object* current = *receiver_;
+ JSReceiver* current = JSReceiver::cast(*receiver_);
JSReceiver* holder = *holder_;
+ if (current == holder) return true;
+ if (!holder->map()->is_hidden_prototype()) return false;
// JSProxy do not occur as hidden prototypes.
- if (current->IsJSProxy()) {
- return JSReceiver::cast(current) == holder;
- }
- PrototypeIterator iter(isolate(), current,
- PrototypeIterator::START_AT_RECEIVER);
- do {
+ if (current->IsJSProxy()) return false;
+ PrototypeIterator iter(isolate(), current);
+ while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) {
if (iter.GetCurrent<JSReceiver>() == holder) return true;
- DCHECK(!current->IsJSProxy());
iter.Advance();
- } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN));
+ }
return false;
}
@@ -419,16 +417,8 @@ Handle<Object> LookupIterator::FetchValue() const {
Object* result = NULL;
if (IsElement()) {
Handle<JSObject> holder = GetHolder<JSObject>();
- // TODO(verwaest): Optimize.
- if (holder->IsStringObjectWithCharacterAt(index_)) {
- Handle<JSValue> js_value = Handle<JSValue>::cast(holder);
- Handle<String> string(String::cast(js_value->value()));
- return factory()->LookupSingleCharacterStringFromCode(
- String::Flatten(string)->Get(index_));
- }
-
ElementsAccessor* accessor = holder->GetElementsAccessor();
- return accessor->Get(handle(holder->elements()), number_);
+ return accessor->Get(holder, number_);
} else if (holder_map_->IsJSGlobalObjectMap()) {
Handle<JSObject> holder = GetHolder<JSObject>();
result = holder->global_dictionary()->ValueAt(number_);
@@ -515,7 +505,7 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
if (IsElement()) {
Handle<JSObject> object = Handle<JSObject>::cast(holder);
ElementsAccessor* accessor = object->GetElementsAccessor();
- accessor->Set(object->elements(), number_, *value);
+ accessor->Set(object, number_, *value);
} else if (holder->IsJSGlobalObject()) {
Handle<GlobalDictionary> property_dictionary =
handle(JSObject::cast(*holder)->global_dictionary());
@@ -625,10 +615,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
}
// Fall through.
case ACCESS_CHECK:
- if (exotic_index_state_ != ExoticIndexState::kNotExotic &&
- holder->IsJSTypedArray() && IsIntegerIndexedExotic(holder)) {
- return INTEGER_INDEXED_EXOTIC;
- }
if (check_interceptor() && HasInterceptor(map) &&
!SkipInterceptor(JSObject::cast(holder))) {
// Do not leak private property names.
@@ -638,25 +624,20 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
// Fall through.
case INTERCEPTOR:
if (IsElement()) {
- // TODO(verwaest): Optimize.
- if (holder->IsStringObjectWithCharacterAt(index_)) {
- PropertyAttributes attributes =
- static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
- property_details_ = PropertyDetails(attributes, v8::internal::DATA, 0,
- PropertyCellType::kNoCell);
- } else {
- JSObject* js_object = JSObject::cast(holder);
- if (js_object->elements() == isolate()->heap()->empty_fixed_array()) {
- return NOT_FOUND;
+ JSObject* js_object = JSObject::cast(holder);
+ ElementsAccessor* accessor = js_object->GetElementsAccessor();
+ FixedArrayBase* backing_store = js_object->elements();
+ number_ = accessor->GetEntryForIndex(js_object, backing_store, index_);
+ if (number_ == kMaxUInt32) {
+ if (*receiver_ == Object::cast(holder) && holder->IsJSTypedArray()) {
+ return INTEGER_INDEXED_EXOTIC;
}
-
- ElementsAccessor* accessor = js_object->GetElementsAccessor();
- FixedArrayBase* backing_store = js_object->elements();
- number_ =
- accessor->GetEntryForIndex(js_object, backing_store, index_);
- if (number_ == kMaxUInt32) return NOT_FOUND;
- property_details_ = accessor->GetDetails(backing_store, number_);
+ return NOT_FOUND;
}
+ property_details_ = accessor->GetDetails(js_object, number_);
+ } else if (exotic_index_state_ != ExoticIndexState::kNotExotic &&
+ holder->IsJSTypedArray() && IsIntegerIndexedExotic(holder)) {
+ return INTEGER_INDEXED_EXOTIC;
} else if (!map->is_dictionary_map()) {
DescriptorArray* descriptors = map->instance_descriptors();
int number = descriptors->SearchWithCache(*name_, map);
« no previous file with comments | « src/key-accumulator.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698