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

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: Addressing review notes Created 6 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 unified diff | Download patch | 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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) 1024 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value())
1025 : reinterpret_cast<HeapNumber*>(this)->value(); 1025 : reinterpret_cast<HeapNumber*>(this)->value();
1026 } 1026 }
1027 1027
1028 1028
1029 bool Object::IsNaN() { 1029 bool Object::IsNaN() {
1030 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); 1030 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value());
1031 } 1031 }
1032 1032
1033 1033
1034 // static
1035 Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) { 1034 Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) {
1036 if (object->IsSmi()) return object; 1035 if (object->IsSmi()) return object;
1037 if (object->IsHeapNumber()) { 1036 if (object->IsHeapNumber()) {
1038 double value = Handle<HeapNumber>::cast(object)->value(); 1037 double value = Handle<HeapNumber>::cast(object)->value();
1039 int int_value = FastD2I(value); 1038 int int_value = FastD2I(value);
1040 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 1039 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
1041 return handle(Smi::FromInt(int_value), isolate); 1040 return handle(Smi::FromInt(int_value), isolate);
1042 } 1041 }
1043 } 1042 }
1044 return Handle<Object>(); 1043 return Handle<Object>();
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 } 1654 }
1656 } 1655 }
1657 1656
1658 if (target_kind != current_kind) { 1657 if (target_kind != current_kind) {
1659 return TransitionElementsKind(target_kind); 1658 return TransitionElementsKind(target_kind);
1660 } 1659 }
1661 return this; 1660 return this;
1662 } 1661 }
1663 1662
1664 1663
1664 // TODO(ishell): Temporary wrapper until handlified.
1665 void JSObject::EnsureCanContainElements(Handle<JSObject> object,
1666 Handle<FixedArrayBase> elements,
1667 uint32_t length,
1668 EnsureElementsMode mode) {
1669 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
1670 object->EnsureCanContainElements(*elements,
1671 length,
1672 mode));
1673 }
1674
1675
1665 MaybeObject* JSObject::EnsureCanContainElements(FixedArrayBase* elements, 1676 MaybeObject* JSObject::EnsureCanContainElements(FixedArrayBase* elements,
1666 uint32_t length, 1677 uint32_t length,
1667 EnsureElementsMode mode) { 1678 EnsureElementsMode mode) {
1668 if (elements->map() != GetHeap()->fixed_double_array_map()) { 1679 if (elements->map() != GetHeap()->fixed_double_array_map()) {
1669 ASSERT(elements->map() == GetHeap()->fixed_array_map() || 1680 ASSERT(elements->map() == GetHeap()->fixed_array_map() ||
1670 elements->map() == GetHeap()->fixed_cow_array_map()); 1681 elements->map() == GetHeap()->fixed_cow_array_map());
1671 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) { 1682 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
1672 mode = DONT_ALLOW_DOUBLE_ELEMENTS; 1683 mode = DONT_ALLOW_DOUBLE_ELEMENTS;
1673 } 1684 }
1674 Object** objects = FixedArray::cast(elements)->GetFirstElementAddress(); 1685 Object** objects = FixedArray::cast(elements)->GetFirstElementAddress();
(...skipping 4886 matching lines...) Expand 10 before | Expand all | Expand 10 after
6561 } 6572 }
6562 6573
6563 6574
6564 bool JSArray::AllowsSetElementsLength() { 6575 bool JSArray::AllowsSetElementsLength() {
6565 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); 6576 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
6566 ASSERT(result == !HasExternalArrayElements()); 6577 ASSERT(result == !HasExternalArrayElements());
6567 return result; 6578 return result;
6568 } 6579 }
6569 6580
6570 6581
6571 MaybeObject* JSArray::SetContent(FixedArrayBase* storage) { 6582 void JSArray::SetContent(Handle<JSArray> array,
6572 MaybeObject* maybe_result = EnsureCanContainElements( 6583 Handle<FixedArrayBase> storage) {
6573 storage, storage->length(), ALLOW_COPIED_DOUBLE_ELEMENTS); 6584 EnsureCanContainElements(array, storage, storage->length(),
6574 if (maybe_result->IsFailure()) return maybe_result; 6585 ALLOW_COPIED_DOUBLE_ELEMENTS);
6575 ASSERT((storage->map() == GetHeap()->fixed_double_array_map() && 6586
6576 IsFastDoubleElementsKind(GetElementsKind())) || 6587 ASSERT((storage->map() == array->GetHeap()->fixed_double_array_map() &&
6577 ((storage->map() != GetHeap()->fixed_double_array_map()) && 6588 IsFastDoubleElementsKind(array->GetElementsKind())) ||
6578 (IsFastObjectElementsKind(GetElementsKind()) || 6589 ((storage->map() != array->GetHeap()->fixed_double_array_map()) &&
6579 (IsFastSmiElementsKind(GetElementsKind()) && 6590 (IsFastObjectElementsKind(array->GetElementsKind()) ||
6580 FixedArray::cast(storage)->ContainsOnlySmisOrHoles())))); 6591 (IsFastSmiElementsKind(array->GetElementsKind()) &&
6581 set_elements(storage); 6592 Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
6582 set_length(Smi::FromInt(storage->length())); 6593 array->set_elements(*storage);
6583 return this; 6594 array->set_length(Smi::FromInt(storage->length()));
6584 } 6595 }
6585 6596
6586 6597
6587 MaybeObject* FixedArray::Copy() { 6598 MaybeObject* FixedArray::Copy() {
6588 if (length() == 0) return this; 6599 if (length() == 0) return this;
6589 return GetHeap()->CopyFixedArray(this); 6600 return GetHeap()->CopyFixedArray(this);
6590 } 6601 }
6591 6602
6592 6603
6593 MaybeObject* FixedDoubleArray::Copy() { 6604 MaybeObject* FixedDoubleArray::Copy() {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
6809 #undef READ_UINT32_FIELD 6820 #undef READ_UINT32_FIELD
6810 #undef WRITE_UINT32_FIELD 6821 #undef WRITE_UINT32_FIELD
6811 #undef READ_SHORT_FIELD 6822 #undef READ_SHORT_FIELD
6812 #undef WRITE_SHORT_FIELD 6823 #undef WRITE_SHORT_FIELD
6813 #undef READ_BYTE_FIELD 6824 #undef READ_BYTE_FIELD
6814 #undef WRITE_BYTE_FIELD 6825 #undef WRITE_BYTE_FIELD
6815 6826
6816 } } // namespace v8::internal 6827 } } // namespace v8::internal
6817 6828
6818 #endif // V8_OBJECTS_INL_H_ 6829 #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
This is Rietveld 408576698