Chromium Code Reviews| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(state_ != LookupIterator::ACCESSOR); |
| 124 DCHECK(state_ != LookupIterator::INTEGER_INDEXED_EXOTIC); | |
|
Toon Verwaest
2015/03/10 12:01:25
DCHECK_NE
dcarney
2015/03/10 13:09:46
Done.
| |
| 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); |
|
Toon Verwaest
2015/03/10 12:01:25
DCHECK_NE
dcarney
2015/03/10 13:09:46
dcheck not okay with this
| |
| 338 Handle<String> name_string = Handle<String>::cast(name()); | 338 if (!holder->IsJSTypedArray()) return false; |
| 339 if (name_string->length() > 0) { | 339 if (exotic_index_state_ == ExoticIndexState::kIndex) return true; |
| 340 double d = | 340 DCHECK(exotic_index_state_ == ExoticIndexState::kUninitialized); |
|
Toon Verwaest
2015/03/10 12:01:25
DCHECK_EQ
dcarney
2015/03/10 13:09:46
same
| |
| 341 StringToDouble(isolate()->unicode_cache(), name_string, NO_FLAGS); | 341 if (!name()->IsString() || String::cast(*name())->length() == 0) { |
| 342 if (!std::isnan(d)) { | 342 exotic_index_state_ = ExoticIndexState::kNoIndex; |
| 343 if (String::Equals(isolate()->factory()->minus_zero_string(), | 343 return false; |
| 344 name_string)) | 344 } |
| 345 return true; | 345 Handle<String> name_string = Handle<String>::cast(name()); |
| 346 | 346 double d = StringToDouble(isolate()->unicode_cache(), name_string, NO_FLAGS); |
| 347 Factory* factory = isolate()->factory(); | 347 if (!std::isnan(d)) { |
| 348 Handle<Object> num = factory->NewNumber(d); | 348 if (String::Equals(isolate()->factory()->minus_zero_string(), |
| 349 Handle<String> roundtrip_string = factory->NumberToString(num); | 349 name_string)) { |
| 350 if (String::Equals(name_string, roundtrip_string)) return true; | 350 exotic_index_state_ = ExoticIndexState::kIndex; |
| 351 } | 351 return true; |
| 352 } | |
| 353 // TODO(dcarney): this could be a lot faster. | |
| 354 AllowHeapAllocation allow; | |
|
Toon Verwaest
2015/03/10 12:01:25
Arg, reallowing allocation is crazy... that's goin
dcarney
2015/03/10 13:09:46
Done.
| |
| 355 Factory* factory = isolate()->factory(); | |
| 356 Handle<Object> num = factory->NewNumber(d); | |
| 357 Handle<String> roundtrip_string = factory->NumberToString(num); | |
| 358 if (String::Equals(name_string, roundtrip_string)) { | |
| 359 exotic_index_state_ = ExoticIndexState::kIndex; | |
| 360 return true; | |
| 352 } | 361 } |
| 353 } | 362 } |
| 363 exotic_index_state_ = ExoticIndexState::kNoIndex; | |
| 354 return false; | 364 return false; |
| 355 } | 365 } |
| 356 | 366 |
| 357 | 367 |
| 358 void LookupIterator::InternalizeName() { | 368 void LookupIterator::InternalizeName() { |
| 359 if (name_->IsUniqueName()) return; | 369 if (name_->IsUniqueName()) return; |
| 360 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 370 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |
| 361 } | 371 } |
| 362 } } // namespace v8::internal | 372 } } // namespace v8::internal |
| OLD | NEW |