Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 11823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11834 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 11834 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 11835 } | 11835 } |
| 11836 | 11836 |
| 11837 | 11837 |
| 11838 void JSArray::Expand(Handle<JSArray> array, int required_size) { | 11838 void JSArray::Expand(Handle<JSArray> array, int required_size) { |
| 11839 ElementsAccessor* accessor = array->GetElementsAccessor(); | 11839 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 11840 accessor->SetCapacityAndLength(array, required_size, required_size); | 11840 accessor->SetCapacityAndLength(array, required_size, required_size); |
| 11841 } | 11841 } |
| 11842 | 11842 |
| 11843 | 11843 |
| 11844 // Returns false if the passed-in index is marked non-configurable, | 11844 // Returns false if the passed-in index is marked non-configurable, which will |
| 11845 // which will cause the ES5 truncation operation to halt, and thus | 11845 // cause the truncation operation to halt, and thus no further old values need |
| 11846 // no further old values need be collected. | 11846 // be collected. |
| 11847 static bool GetOldValue(Isolate* isolate, | 11847 static bool GetOldValue(Isolate* isolate, |
| 11848 Handle<JSObject> object, | 11848 Handle<JSObject> object, |
| 11849 uint32_t index, | 11849 uint32_t index, |
| 11850 List<Handle<Object> >* old_values, | 11850 List<Handle<Object> >* old_values, |
| 11851 List<uint32_t>* indices) { | 11851 List<uint32_t>* indices) { |
| 11852 Maybe<PropertyAttributes> maybe = | 11852 LookupIterator it(isolate, object, index, LookupIterator::HIDDEN); |
| 11853 JSReceiver::GetOwnElementAttributes(object, index); | 11853 CHECK(JSReceiver::GetPropertyAttributes(&it).IsJust()); |
|
Jakob Kummerow
2015/06/11 14:35:24
Can this be a DCHECK?
Toon Verwaest
2015/06/11 14:46:26
No, in that case it wouldn't run in release mode.
| |
| 11854 DCHECK(maybe.IsJust()); | 11854 DCHECK(it.IsFound()); |
| 11855 DCHECK(maybe.FromJust() != ABSENT); | 11855 if (!it.IsConfigurable()) return false; |
| 11856 if (maybe.FromJust() == DONT_DELETE) return false; | 11856 Handle<Object> value = |
| 11857 Handle<Object> value; | 11857 it.state() == LookupIterator::ACCESSOR |
| 11858 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) { | 11858 ? Handle<Object>::cast(isolate->factory()->the_hole_value()) |
| 11859 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); | 11859 : JSReceiver::GetDataProperty(&it); |
| 11860 } else { | |
| 11861 value = Object::GetElement(isolate, object, index).ToHandleChecked(); | |
| 11862 } | |
| 11863 old_values->Add(value); | 11860 old_values->Add(value); |
| 11864 indices->Add(index); | 11861 indices->Add(index); |
| 11865 return true; | 11862 return true; |
| 11866 } | 11863 } |
| 11867 | 11864 |
| 11868 MaybeHandle<Object> JSArray::SetElementsLength( | 11865 MaybeHandle<Object> JSArray::SetElementsLength( |
| 11869 Handle<JSArray> array, | 11866 Handle<JSArray> array, |
| 11870 Handle<Object> new_length_handle) { | 11867 Handle<Object> new_length_handle) { |
| 11871 if (array->HasFastElements() && | 11868 if (array->HasFastElements() && |
| 11872 SetElementsLengthWouldNormalize(array->GetHeap(), new_length_handle)) { | 11869 SetElementsLengthWouldNormalize(array->GetHeap(), new_length_handle)) { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12355 uint32_t arg_count, | 12352 uint32_t arg_count, |
| 12356 EnsureElementsMode mode) { | 12353 EnsureElementsMode mode) { |
| 12357 // Elements in |Arguments| are ordered backwards (because they're on the | 12354 // Elements in |Arguments| are ordered backwards (because they're on the |
| 12358 // stack), but the method that's called here iterates over them in forward | 12355 // stack), but the method that's called here iterates over them in forward |
| 12359 // direction. | 12356 // direction. |
| 12360 return EnsureCanContainElements( | 12357 return EnsureCanContainElements( |
| 12361 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); | 12358 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); |
| 12362 } | 12359 } |
| 12363 | 12360 |
| 12364 | 12361 |
| 12365 MaybeHandle<AccessorPair> JSObject::GetOwnElementAccessorPair( | |
| 12366 Handle<JSObject> object, | |
| 12367 uint32_t index) { | |
| 12368 if (object->IsJSGlobalProxy()) { | |
| 12369 PrototypeIterator iter(object->GetIsolate(), object); | |
| 12370 if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>(); | |
| 12371 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | |
| 12372 return GetOwnElementAccessorPair( | |
| 12373 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); | |
| 12374 } | |
| 12375 | |
| 12376 // Check for lookup interceptor. | |
| 12377 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); | |
| 12378 | |
| 12379 return object->GetElementsAccessor()->GetAccessorPair(object, index); | |
| 12380 } | |
| 12381 | |
| 12382 | |
| 12383 bool JSObject::HasFastArgumentsElements() { | 12362 bool JSObject::HasFastArgumentsElements() { |
| 12384 Heap* heap = GetHeap(); | 12363 Heap* heap = GetHeap(); |
| 12385 if (!elements()->IsFixedArray()) return false; | 12364 if (!elements()->IsFixedArray()) return false; |
| 12386 FixedArray* elements = FixedArray::cast(this->elements()); | 12365 FixedArray* elements = FixedArray::cast(this->elements()); |
| 12387 if (elements->map() != heap->sloppy_arguments_elements_map()) { | 12366 if (elements->map() != heap->sloppy_arguments_elements_map()) { |
| 12388 return false; | 12367 return false; |
| 12389 } | 12368 } |
| 12390 FixedArray* arguments = FixedArray::cast(elements->get(1)); | 12369 FixedArray* arguments = FixedArray::cast(elements->get(1)); |
| 12391 return !arguments->IsDictionary(); | 12370 return !arguments->IsDictionary(); |
| 12392 } | 12371 } |
| (...skipping 4237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16630 Handle<Object> new_value) { | 16609 Handle<Object> new_value) { |
| 16631 if (cell->value() != *new_value) { | 16610 if (cell->value() != *new_value) { |
| 16632 cell->set_value(*new_value); | 16611 cell->set_value(*new_value); |
| 16633 Isolate* isolate = cell->GetIsolate(); | 16612 Isolate* isolate = cell->GetIsolate(); |
| 16634 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16613 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 16635 isolate, DependentCode::kPropertyCellChangedGroup); | 16614 isolate, DependentCode::kPropertyCellChangedGroup); |
| 16636 } | 16615 } |
| 16637 } | 16616 } |
| 16638 } // namespace internal | 16617 } // namespace internal |
| 16639 } // namespace v8 | 16618 } // namespace v8 |
| OLD | NEW |