| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.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/lookup.h" | 9 #include "src/lookup.h" |
| 10 #include "src/lookup-inl.h" | 10 #include "src/lookup-inl.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 | 114 |
| 115 ReloadPropertyInformation(); | 115 ReloadPropertyInformation(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 | 118 |
| 119 void LookupIterator::PrepareTransitionToDataProperty( | 119 void LookupIterator::PrepareTransitionToDataProperty( |
| 120 Handle<Object> value, PropertyAttributes attributes, | 120 Handle<Object> value, PropertyAttributes attributes, |
| 121 Object::StoreFromKeyed store_mode) { | 121 Object::StoreFromKeyed store_mode) { |
| 122 if (state_ == TRANSITION) return; | 122 if (state_ == TRANSITION) return; |
| 123 DCHECK(state_ != LookupIterator::ACCESSOR); | 123 DCHECK_NE(LookupIterator::ACCESSOR, state_); |
| 124 DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, state_); |
| 124 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); | 125 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); |
| 125 DCHECK(!IsSpecialNumericIndex()); | |
| 126 // Can only be called when the receiver is a JSObject. JSProxy has to be | 126 // Can only be called when the receiver is a JSObject. JSProxy has to be |
| 127 // handled via a trap. Adding properties to primitive values is not | 127 // handled via a trap. Adding properties to primitive values is not |
| 128 // observable. | 128 // observable. |
| 129 Handle<JSObject> receiver = GetStoreTarget(); | 129 Handle<JSObject> receiver = GetStoreTarget(); |
| 130 | 130 |
| 131 if (!isolate()->IsInternallyUsedPropertyName(name()) && | 131 if (!isolate()->IsInternallyUsedPropertyName(name()) && |
| 132 !receiver->map()->is_extensible()) { | 132 !receiver->map()->is_extensible()) { |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 326 } |
| 327 } else if (property_details_.type() == v8::internal::DATA) { | 327 } else if (property_details_.type() == v8::internal::DATA) { |
| 328 holder->WriteToField(descriptor_number(), *value); | 328 holder->WriteToField(descriptor_number(), *value); |
| 329 } else { | 329 } else { |
| 330 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); | 330 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); |
| 331 } | 331 } |
| 332 return value; | 332 return value; |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 bool LookupIterator::IsSpecialNumericIndex() const { | 336 bool LookupIterator::IsIntegerIndexedExotic(JSReceiver* holder) { |
| 337 if (GetStoreTarget()->IsJSTypedArray() && name()->IsString()) { | 337 DCHECK(exotic_index_state_ != ExoticIndexState::kNoIndex); |
| 338 // Currently typed arrays are the only such objects. |
| 339 if (!holder->IsJSTypedArray()) return false; |
| 340 if (exotic_index_state_ == ExoticIndexState::kIndex) return true; |
| 341 DCHECK(exotic_index_state_ == ExoticIndexState::kUninitialized); |
| 342 bool result = false; |
| 343 // Compute and cache result. |
| 344 if (name()->IsString()) { |
| 338 Handle<String> name_string = Handle<String>::cast(name()); | 345 Handle<String> name_string = Handle<String>::cast(name()); |
| 339 if (name_string->length() > 0) { | 346 if (name_string->length() != 0) { |
| 340 double d = | 347 result = IsNonArrayIndexInteger(*name_string); |
| 341 StringToDouble(isolate()->unicode_cache(), name_string, NO_FLAGS); | |
| 342 if (!std::isnan(d)) { | |
| 343 if (String::Equals(isolate()->factory()->minus_zero_string(), | |
| 344 name_string)) | |
| 345 return true; | |
| 346 | |
| 347 Factory* factory = isolate()->factory(); | |
| 348 Handle<Object> num = factory->NewNumber(d); | |
| 349 Handle<String> roundtrip_string = factory->NumberToString(num); | |
| 350 if (String::Equals(name_string, roundtrip_string)) return true; | |
| 351 } | |
| 352 } | 348 } |
| 353 } | 349 } |
| 354 return false; | 350 exotic_index_state_ = |
| 351 result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex; |
| 352 return result; |
| 355 } | 353 } |
| 356 | 354 |
| 357 | 355 |
| 358 void LookupIterator::InternalizeName() { | 356 void LookupIterator::InternalizeName() { |
| 359 if (name_->IsUniqueName()) return; | 357 if (name_->IsUniqueName()) return; |
| 360 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 358 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |
| 361 } | 359 } |
| 362 } } // namespace v8::internal | 360 } } // namespace v8::internal |
| OLD | NEW |