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

Side by Side Diff: src/objects.cc

Issue 7461018: Implement for..in for FastDoubleArrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 5 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 | « no previous file | test/mjsunit/unbox-double-arrays.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 8124 matching lines...) Expand 10 before | Expand all | Expand 10 after
8135 switch (kind) { 8135 switch (kind) {
8136 case FAST_ELEMENTS: { 8136 case FAST_ELEMENTS: {
8137 uint32_t length = IsJSArray() ? 8137 uint32_t length = IsJSArray() ?
8138 static_cast<uint32_t> 8138 static_cast<uint32_t>
8139 (Smi::cast(JSArray::cast(this)->length())->value()) : 8139 (Smi::cast(JSArray::cast(this)->length())->value()) :
8140 static_cast<uint32_t>(FixedArray::cast(elements())->length()); 8140 static_cast<uint32_t>(FixedArray::cast(elements())->length());
8141 if ((index < length) && 8141 if ((index < length) &&
8142 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; 8142 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true;
8143 break; 8143 break;
8144 } 8144 }
8145 case FAST_DOUBLE_ELEMENTS: {
8146 uint32_t length = IsJSArray() ?
8147 static_cast<uint32_t>
8148 (Smi::cast(JSArray::cast(this)->length())->value()) :
8149 static_cast<uint32_t>(FixedDoubleArray::cast(elements())->length());
8150 if ((index < length) &&
8151 !FixedDoubleArray::cast(elements())->is_the_hole(index)) return true;
8152 break;
8153 }
8145 case EXTERNAL_PIXEL_ELEMENTS: { 8154 case EXTERNAL_PIXEL_ELEMENTS: {
8146 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); 8155 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
8147 if (index < static_cast<uint32_t>(pixels->length())) { 8156 if (index < static_cast<uint32_t>(pixels->length())) {
8148 return true; 8157 return true;
8149 } 8158 }
8150 break; 8159 break;
8151 } 8160 }
8152 case EXTERNAL_BYTE_ELEMENTS: 8161 case EXTERNAL_BYTE_ELEMENTS:
8153 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 8162 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
8154 case EXTERNAL_SHORT_ELEMENTS: 8163 case EXTERNAL_SHORT_ELEMENTS:
8155 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 8164 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
8156 case EXTERNAL_INT_ELEMENTS: 8165 case EXTERNAL_INT_ELEMENTS:
8157 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 8166 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
8158 case EXTERNAL_FLOAT_ELEMENTS: 8167 case EXTERNAL_FLOAT_ELEMENTS:
8159 case EXTERNAL_DOUBLE_ELEMENTS: { 8168 case EXTERNAL_DOUBLE_ELEMENTS: {
8160 ExternalArray* array = ExternalArray::cast(elements()); 8169 ExternalArray* array = ExternalArray::cast(elements());
8161 if (index < static_cast<uint32_t>(array->length())) { 8170 if (index < static_cast<uint32_t>(array->length())) {
8162 return true; 8171 return true;
8163 } 8172 }
8164 break; 8173 break;
8165 } 8174 }
8166 case FAST_DOUBLE_ELEMENTS:
8167 UNREACHABLE();
8168 break;
8169 case DICTIONARY_ELEMENTS: { 8175 case DICTIONARY_ELEMENTS: {
8170 if (element_dictionary()->FindEntry(index) 8176 if (element_dictionary()->FindEntry(index)
8171 != NumberDictionary::kNotFound) { 8177 != NumberDictionary::kNotFound) {
8172 return true; 8178 return true;
8173 } 8179 }
8174 break; 8180 break;
8175 } 8181 }
8176 case NON_STRICT_ARGUMENTS_ELEMENTS: { 8182 case NON_STRICT_ARGUMENTS_ELEMENTS: {
8177 FixedArray* parameter_map = FixedArray::cast(elements()); 8183 FixedArray* parameter_map = FixedArray::cast(elements());
8178 uint32_t length = parameter_map->length(); 8184 uint32_t length = parameter_map->length();
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
9596 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { 9602 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) {
9597 if (storage != NULL) { 9603 if (storage != NULL) {
9598 storage->set(counter, Smi::FromInt(i)); 9604 storage->set(counter, Smi::FromInt(i));
9599 } 9605 }
9600 counter++; 9606 counter++;
9601 } 9607 }
9602 } 9608 }
9603 ASSERT(!storage || storage->length() >= counter); 9609 ASSERT(!storage || storage->length() >= counter);
9604 break; 9610 break;
9605 } 9611 }
9612 case FAST_DOUBLE_ELEMENTS: {
9613 int length = IsJSArray() ?
9614 Smi::cast(JSArray::cast(this)->length())->value() :
9615 FixedDoubleArray::cast(elements())->length();
9616 for (int i = 0; i < length; i++) {
9617 if (!FixedDoubleArray::cast(elements())->is_the_hole(i)) {
9618 if (storage != NULL) {
9619 storage->set(counter, Smi::FromInt(i));
9620 }
9621 counter++;
9622 }
9623 }
9624 ASSERT(!storage || storage->length() >= counter);
9625 break;
9626 }
9606 case EXTERNAL_PIXEL_ELEMENTS: { 9627 case EXTERNAL_PIXEL_ELEMENTS: {
9607 int length = ExternalPixelArray::cast(elements())->length(); 9628 int length = ExternalPixelArray::cast(elements())->length();
9608 while (counter < length) { 9629 while (counter < length) {
9609 if (storage != NULL) { 9630 if (storage != NULL) {
9610 storage->set(counter, Smi::FromInt(counter)); 9631 storage->set(counter, Smi::FromInt(counter));
9611 } 9632 }
9612 counter++; 9633 counter++;
9613 } 9634 }
9614 ASSERT(!storage || storage->length() >= counter); 9635 ASSERT(!storage || storage->length() >= counter);
9615 break; 9636 break;
9616 } 9637 }
9617 case EXTERNAL_BYTE_ELEMENTS: 9638 case EXTERNAL_BYTE_ELEMENTS:
9618 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 9639 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
9619 case EXTERNAL_SHORT_ELEMENTS: 9640 case EXTERNAL_SHORT_ELEMENTS:
9620 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 9641 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
9621 case EXTERNAL_INT_ELEMENTS: 9642 case EXTERNAL_INT_ELEMENTS:
9622 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 9643 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
9623 case EXTERNAL_FLOAT_ELEMENTS: 9644 case EXTERNAL_FLOAT_ELEMENTS:
9624 case EXTERNAL_DOUBLE_ELEMENTS: { 9645 case EXTERNAL_DOUBLE_ELEMENTS: {
9625 int length = ExternalArray::cast(elements())->length(); 9646 int length = ExternalArray::cast(elements())->length();
9626 while (counter < length) { 9647 while (counter < length) {
9627 if (storage != NULL) { 9648 if (storage != NULL) {
9628 storage->set(counter, Smi::FromInt(counter)); 9649 storage->set(counter, Smi::FromInt(counter));
9629 } 9650 }
9630 counter++; 9651 counter++;
9631 } 9652 }
9632 ASSERT(!storage || storage->length() >= counter); 9653 ASSERT(!storage || storage->length() >= counter);
9633 break; 9654 break;
9634 } 9655 }
9635 case FAST_DOUBLE_ELEMENTS:
9636 UNREACHABLE();
9637 break;
9638 case DICTIONARY_ELEMENTS: { 9656 case DICTIONARY_ELEMENTS: {
9639 if (storage != NULL) { 9657 if (storage != NULL) {
9640 element_dictionary()->CopyKeysTo(storage, 9658 element_dictionary()->CopyKeysTo(storage,
9641 filter, 9659 filter,
9642 NumberDictionary::SORTED); 9660 NumberDictionary::SORTED);
9643 } 9661 }
9644 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter); 9662 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter);
9645 break; 9663 break;
9646 } 9664 }
9647 case NON_STRICT_ARGUMENTS_ELEMENTS: { 9665 case NON_STRICT_ARGUMENTS_ELEMENTS: {
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after
11818 if (break_point_objects()->IsUndefined()) return 0; 11836 if (break_point_objects()->IsUndefined()) return 0;
11819 // Single beak point. 11837 // Single beak point.
11820 if (!break_point_objects()->IsFixedArray()) return 1; 11838 if (!break_point_objects()->IsFixedArray()) return 1;
11821 // Multiple break points. 11839 // Multiple break points.
11822 return FixedArray::cast(break_point_objects())->length(); 11840 return FixedArray::cast(break_point_objects())->length();
11823 } 11841 }
11824 #endif 11842 #endif
11825 11843
11826 11844
11827 } } // namespace v8::internal 11845 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/unbox-double-arrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698