Chromium Code Reviews

Side by Side Diff: src/objects-inl.h

Issue 206223003: JSArray::SetContent() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1644 matching lines...)
1655 } 1655 }
1656 } 1656 }
1657 1657
1658 if (target_kind != current_kind) { 1658 if (target_kind != current_kind) {
1659 return TransitionElementsKind(target_kind); 1659 return TransitionElementsKind(target_kind);
1660 } 1660 }
1661 return this; 1661 return this;
1662 } 1662 }
1663 1663
1664 1664
1665 // TODO(ishell): Temporary wrapper until handlified.
1666 // static
1667 void JSObject::EnsureCanContainElements(Handle<JSObject> object,
1668 Handle<FixedArrayBase> elements,
1669 uint32_t length,
1670 EnsureElementsMode mode) {
1671 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
1672 object->EnsureCanContainElements(*elements,
1673 length,
1674 mode));
1675 }
1676
1677
1665 MaybeObject* JSObject::EnsureCanContainElements(FixedArrayBase* elements, 1678 MaybeObject* JSObject::EnsureCanContainElements(FixedArrayBase* elements,
1666 uint32_t length, 1679 uint32_t length,
1667 EnsureElementsMode mode) { 1680 EnsureElementsMode mode) {
1668 if (elements->map() != GetHeap()->fixed_double_array_map()) { 1681 if (elements->map() != GetHeap()->fixed_double_array_map()) {
1669 ASSERT(elements->map() == GetHeap()->fixed_array_map() || 1682 ASSERT(elements->map() == GetHeap()->fixed_array_map() ||
1670 elements->map() == GetHeap()->fixed_cow_array_map()); 1683 elements->map() == GetHeap()->fixed_cow_array_map());
1671 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) { 1684 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
1672 mode = DONT_ALLOW_DOUBLE_ELEMENTS; 1685 mode = DONT_ALLOW_DOUBLE_ELEMENTS;
1673 } 1686 }
1674 Object** objects = FixedArray::cast(elements)->GetFirstElementAddress(); 1687 Object** objects = FixedArray::cast(elements)->GetFirstElementAddress();
(...skipping 4886 matching lines...)
6561 } 6574 }
6562 6575
6563 6576
6564 bool JSArray::AllowsSetElementsLength() { 6577 bool JSArray::AllowsSetElementsLength() {
6565 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); 6578 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
6566 ASSERT(result == !HasExternalArrayElements()); 6579 ASSERT(result == !HasExternalArrayElements());
6567 return result; 6580 return result;
6568 } 6581 }
6569 6582
6570 6583
6571 MaybeObject* JSArray::SetContent(FixedArrayBase* storage) { 6584 // static
Yang 2014/03/20 15:26:38 We don't have the convention of denoting implement
Igor Sheludko 2014/03/21 08:25:12 Done.
6572 MaybeObject* maybe_result = EnsureCanContainElements( 6585 void JSArray::SetContent(Handle<JSArray> array,
6573 storage, storage->length(), ALLOW_COPIED_DOUBLE_ELEMENTS); 6586 Handle<FixedArrayBase> storage) {
6574 if (maybe_result->IsFailure()) return maybe_result; 6587 EnsureCanContainElements(array, storage, storage->length(),
6575 ASSERT((storage->map() == GetHeap()->fixed_double_array_map() && 6588 ALLOW_COPIED_DOUBLE_ELEMENTS);
6576 IsFastDoubleElementsKind(GetElementsKind())) || 6589
6577 ((storage->map() != GetHeap()->fixed_double_array_map()) && 6590 ASSERT((storage->map() == array->GetHeap()->fixed_double_array_map() &&
6578 (IsFastObjectElementsKind(GetElementsKind()) || 6591 IsFastDoubleElementsKind(array->GetElementsKind())) ||
6579 (IsFastSmiElementsKind(GetElementsKind()) && 6592 ((storage->map() != array->GetHeap()->fixed_double_array_map()) &&
6580 FixedArray::cast(storage)->ContainsOnlySmisOrHoles())))); 6593 (IsFastObjectElementsKind(array->GetElementsKind()) ||
6581 set_elements(storage); 6594 (IsFastSmiElementsKind(array->GetElementsKind()) &&
6582 set_length(Smi::FromInt(storage->length())); 6595 Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
6583 return this; 6596 array->set_elements(*storage);
6597 array->set_length(Smi::FromInt(storage->length()));
6584 } 6598 }
6585 6599
6586 6600
6587 MaybeObject* FixedArray::Copy() { 6601 MaybeObject* FixedArray::Copy() {
6588 if (length() == 0) return this; 6602 if (length() == 0) return this;
6589 return GetHeap()->CopyFixedArray(this); 6603 return GetHeap()->CopyFixedArray(this);
6590 } 6604 }
6591 6605
6592 6606
6593 MaybeObject* FixedDoubleArray::Copy() { 6607 MaybeObject* FixedDoubleArray::Copy() {
(...skipping 215 matching lines...)
6809 #undef READ_UINT32_FIELD 6823 #undef READ_UINT32_FIELD
6810 #undef WRITE_UINT32_FIELD 6824 #undef WRITE_UINT32_FIELD
6811 #undef READ_SHORT_FIELD 6825 #undef READ_SHORT_FIELD
6812 #undef WRITE_SHORT_FIELD 6826 #undef WRITE_SHORT_FIELD
6813 #undef READ_BYTE_FIELD 6827 #undef READ_BYTE_FIELD
6814 #undef WRITE_BYTE_FIELD 6828 #undef WRITE_BYTE_FIELD
6815 6829
6816 } } // namespace v8::internal 6830 } } // namespace v8::internal
6817 6831
6818 #endif // V8_OBJECTS_INL_H_ 6832 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine