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

Unified Diff: src/lookup.cc

Issue 992913002: handle the special snowflakes that are Integer Indexed Exotic objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/lookup.h ('k') | src/lookup-inl.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 b629f1980cac6c080c323766167295b46efe55f1..9c44dcec4d416cced3fe1b1b87166c903d2ca326 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -120,9 +120,9 @@ void LookupIterator::PrepareTransitionToDataProperty(
Handle<Object> value, PropertyAttributes attributes,
Object::StoreFromKeyed store_mode) {
if (state_ == TRANSITION) return;
- DCHECK(state_ != LookupIterator::ACCESSOR);
+ DCHECK_NE(LookupIterator::ACCESSOR, state_);
+ DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, state_);
DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype());
- DCHECK(!IsSpecialNumericIndex());
// Can only be called when the receiver is a JSObject. JSProxy has to be
// handled via a trap. Adding properties to primitive values is not
// observable.
@@ -333,25 +333,23 @@ Handle<Object> LookupIterator::WriteDataValue(Handle<Object> value) {
}
-bool LookupIterator::IsSpecialNumericIndex() const {
- if (GetStoreTarget()->IsJSTypedArray() && name()->IsString()) {
+bool LookupIterator::IsIntegerIndexedExotic(JSReceiver* holder) {
+ DCHECK(exotic_index_state_ != ExoticIndexState::kNoIndex);
+ // Currently typed arrays are the only such objects.
+ if (!holder->IsJSTypedArray()) return false;
+ if (exotic_index_state_ == ExoticIndexState::kIndex) return true;
+ DCHECK(exotic_index_state_ == ExoticIndexState::kUninitialized);
+ bool result = false;
+ // Compute and cache result.
+ if (name()->IsString()) {
Handle<String> name_string = Handle<String>::cast(name());
- if (name_string->length() > 0) {
- double d =
- StringToDouble(isolate()->unicode_cache(), name_string, NO_FLAGS);
- if (!std::isnan(d)) {
- if (String::Equals(isolate()->factory()->minus_zero_string(),
- name_string))
- return true;
-
- Factory* factory = isolate()->factory();
- Handle<Object> num = factory->NewNumber(d);
- Handle<String> roundtrip_string = factory->NumberToString(num);
- if (String::Equals(name_string, roundtrip_string)) return true;
- }
+ if (name_string->length() != 0) {
+ result = IsNonArrayIndexInteger(*name_string);
}
}
- return false;
+ exotic_index_state_ =
+ result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex;
+ return result;
}
« 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