OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 switch (map()->instance_type()) { | 953 switch (map()->instance_type()) { |
954 case MAP_TYPE: | 954 case MAP_TYPE: |
955 accumulator->Add("<Map>"); | 955 accumulator->Add("<Map>"); |
956 break; | 956 break; |
957 case FIXED_ARRAY_TYPE: | 957 case FIXED_ARRAY_TYPE: |
958 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); | 958 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); |
959 break; | 959 break; |
960 case BYTE_ARRAY_TYPE: | 960 case BYTE_ARRAY_TYPE: |
961 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); | 961 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); |
962 break; | 962 break; |
963 case PIXEL_ARRAY_TYPE: | 963 case EXTERNAL_PIXEL_ARRAY_TYPE: |
964 accumulator->Add("<PixelArray[%u]>", PixelArray::cast(this)->length()); | 964 accumulator->Add("<ExternalPixelArray[%u]>", |
| 965 ExternalPixelArray::cast(this)->length()); |
965 break; | 966 break; |
966 case EXTERNAL_BYTE_ARRAY_TYPE: | 967 case EXTERNAL_BYTE_ARRAY_TYPE: |
967 accumulator->Add("<ExternalByteArray[%u]>", | 968 accumulator->Add("<ExternalByteArray[%u]>", |
968 ExternalByteArray::cast(this)->length()); | 969 ExternalByteArray::cast(this)->length()); |
969 break; | 970 break; |
970 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | 971 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
971 accumulator->Add("<ExternalUnsignedByteArray[%u]>", | 972 accumulator->Add("<ExternalUnsignedByteArray[%u]>", |
972 ExternalUnsignedByteArray::cast(this)->length()); | 973 ExternalUnsignedByteArray::cast(this)->length()); |
973 break; | 974 break; |
974 case EXTERNAL_SHORT_ARRAY_TYPE: | 975 case EXTERNAL_SHORT_ARRAY_TYPE: |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 break; | 1106 break; |
1106 case CODE_TYPE: | 1107 case CODE_TYPE: |
1107 reinterpret_cast<Code*>(this)->CodeIterateBody(v); | 1108 reinterpret_cast<Code*>(this)->CodeIterateBody(v); |
1108 break; | 1109 break; |
1109 case JS_GLOBAL_PROPERTY_CELL_TYPE: | 1110 case JS_GLOBAL_PROPERTY_CELL_TYPE: |
1110 JSGlobalPropertyCell::BodyDescriptor::IterateBody(this, v); | 1111 JSGlobalPropertyCell::BodyDescriptor::IterateBody(this, v); |
1111 break; | 1112 break; |
1112 case HEAP_NUMBER_TYPE: | 1113 case HEAP_NUMBER_TYPE: |
1113 case FILLER_TYPE: | 1114 case FILLER_TYPE: |
1114 case BYTE_ARRAY_TYPE: | 1115 case BYTE_ARRAY_TYPE: |
1115 case PIXEL_ARRAY_TYPE: | 1116 case EXTERNAL_PIXEL_ARRAY_TYPE: |
1116 case EXTERNAL_BYTE_ARRAY_TYPE: | 1117 case EXTERNAL_BYTE_ARRAY_TYPE: |
1117 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | 1118 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
1118 case EXTERNAL_SHORT_ARRAY_TYPE: | 1119 case EXTERNAL_SHORT_ARRAY_TYPE: |
1119 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | 1120 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
1120 case EXTERNAL_INT_ARRAY_TYPE: | 1121 case EXTERNAL_INT_ARRAY_TYPE: |
1121 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | 1122 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
1122 case EXTERNAL_FLOAT_ARRAY_TYPE: | 1123 case EXTERNAL_FLOAT_ARRAY_TYPE: |
1123 break; | 1124 break; |
1124 case SHARED_FUNCTION_INFO_TYPE: | 1125 case SHARED_FUNCTION_INFO_TYPE: |
1125 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); | 1126 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 | 2430 |
2430 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { | 2431 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { |
2431 if (HasFastProperties()) return this; | 2432 if (HasFastProperties()) return this; |
2432 ASSERT(!IsGlobalObject()); | 2433 ASSERT(!IsGlobalObject()); |
2433 return property_dictionary()-> | 2434 return property_dictionary()-> |
2434 TransformPropertiesToFastFor(this, unused_property_fields); | 2435 TransformPropertiesToFastFor(this, unused_property_fields); |
2435 } | 2436 } |
2436 | 2437 |
2437 | 2438 |
2438 MaybeObject* JSObject::NormalizeElements() { | 2439 MaybeObject* JSObject::NormalizeElements() { |
2439 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 2440 ASSERT(!HasExternalArrayElements()); |
2440 if (HasDictionaryElements()) return this; | 2441 if (HasDictionaryElements()) return this; |
2441 ASSERT(map()->has_fast_elements()); | 2442 ASSERT(map()->has_fast_elements()); |
2442 | 2443 |
2443 Object* obj; | 2444 Object* obj; |
2444 { MaybeObject* maybe_obj = map()->GetSlowElementsMap(); | 2445 { MaybeObject* maybe_obj = map()->GetSlowElementsMap(); |
2445 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2446 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2446 } | 2447 } |
2447 Map* new_map = Map::cast(obj); | 2448 Map* new_map = Map::cast(obj); |
2448 | 2449 |
2449 // Get number of entries. | 2450 // Get number of entries. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 } | 2532 } |
2532 MaybeObject* raw_result = | 2533 MaybeObject* raw_result = |
2533 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); | 2534 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); |
2534 RETURN_IF_SCHEDULED_EXCEPTION(); | 2535 RETURN_IF_SCHEDULED_EXCEPTION(); |
2535 return raw_result; | 2536 return raw_result; |
2536 } | 2537 } |
2537 | 2538 |
2538 | 2539 |
2539 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, | 2540 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, |
2540 DeleteMode mode) { | 2541 DeleteMode mode) { |
2541 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 2542 ASSERT(!HasExternalArrayElements()); |
2542 switch (GetElementsKind()) { | 2543 switch (GetElementsKind()) { |
2543 case FAST_ELEMENTS: { | 2544 case FAST_ELEMENTS: { |
2544 Object* obj; | 2545 Object* obj; |
2545 { MaybeObject* maybe_obj = EnsureWritableFastElements(); | 2546 { MaybeObject* maybe_obj = EnsureWritableFastElements(); |
2546 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2547 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2547 } | 2548 } |
2548 uint32_t length = IsJSArray() ? | 2549 uint32_t length = IsJSArray() ? |
2549 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2550 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2550 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2551 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2551 if (index < length) { | 2552 if (index < length) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2630 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2631 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2631 } | 2632 } |
2632 uint32_t length = IsJSArray() ? | 2633 uint32_t length = IsJSArray() ? |
2633 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2634 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2634 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2635 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2635 if (index < length) { | 2636 if (index < length) { |
2636 FixedArray::cast(elements())->set_the_hole(index); | 2637 FixedArray::cast(elements())->set_the_hole(index); |
2637 } | 2638 } |
2638 break; | 2639 break; |
2639 } | 2640 } |
2640 case PIXEL_ELEMENTS: | 2641 case EXTERNAL_PIXEL_ELEMENTS: |
2641 case EXTERNAL_BYTE_ELEMENTS: | 2642 case EXTERNAL_BYTE_ELEMENTS: |
2642 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2643 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2643 case EXTERNAL_SHORT_ELEMENTS: | 2644 case EXTERNAL_SHORT_ELEMENTS: |
2644 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2645 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2645 case EXTERNAL_INT_ELEMENTS: | 2646 case EXTERNAL_INT_ELEMENTS: |
2646 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2647 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2647 case EXTERNAL_FLOAT_ELEMENTS: | 2648 case EXTERNAL_FLOAT_ELEMENTS: |
2648 // Pixel and external array elements cannot be deleted. Just | 2649 // Pixel and external array elements cannot be deleted. Just |
2649 // silently ignore here. | 2650 // silently ignore here. |
2650 break; | 2651 break; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 } | 2746 } |
2746 | 2747 |
2747 // Check if the object is among the named properties. | 2748 // Check if the object is among the named properties. |
2748 Object* key = SlowReverseLookup(obj); | 2749 Object* key = SlowReverseLookup(obj); |
2749 if (key != Heap::undefined_value()) { | 2750 if (key != Heap::undefined_value()) { |
2750 return true; | 2751 return true; |
2751 } | 2752 } |
2752 | 2753 |
2753 // Check if the object is among the indexed properties. | 2754 // Check if the object is among the indexed properties. |
2754 switch (GetElementsKind()) { | 2755 switch (GetElementsKind()) { |
2755 case PIXEL_ELEMENTS: | 2756 case EXTERNAL_PIXEL_ELEMENTS: |
2756 case EXTERNAL_BYTE_ELEMENTS: | 2757 case EXTERNAL_BYTE_ELEMENTS: |
2757 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2758 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2758 case EXTERNAL_SHORT_ELEMENTS: | 2759 case EXTERNAL_SHORT_ELEMENTS: |
2759 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2760 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2760 case EXTERNAL_INT_ELEMENTS: | 2761 case EXTERNAL_INT_ELEMENTS: |
2761 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2762 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2762 case EXTERNAL_FLOAT_ELEMENTS: | 2763 case EXTERNAL_FLOAT_ELEMENTS: |
2763 // Raw pixels and external arrays do not reference other | 2764 // Raw pixels and external arrays do not reference other |
2764 // objects. | 2765 // objects. |
2765 break; | 2766 break; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 return Heap::undefined_value(); | 3006 return Heap::undefined_value(); |
3006 } | 3007 } |
3007 | 3008 |
3008 uint32_t index = 0; | 3009 uint32_t index = 0; |
3009 bool is_element = name->AsArrayIndex(&index); | 3010 bool is_element = name->AsArrayIndex(&index); |
3010 | 3011 |
3011 if (is_element) { | 3012 if (is_element) { |
3012 switch (GetElementsKind()) { | 3013 switch (GetElementsKind()) { |
3013 case FAST_ELEMENTS: | 3014 case FAST_ELEMENTS: |
3014 break; | 3015 break; |
3015 case PIXEL_ELEMENTS: | 3016 case EXTERNAL_PIXEL_ELEMENTS: |
3016 case EXTERNAL_BYTE_ELEMENTS: | 3017 case EXTERNAL_BYTE_ELEMENTS: |
3017 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3018 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3018 case EXTERNAL_SHORT_ELEMENTS: | 3019 case EXTERNAL_SHORT_ELEMENTS: |
3019 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3020 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3020 case EXTERNAL_INT_ELEMENTS: | 3021 case EXTERNAL_INT_ELEMENTS: |
3021 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3022 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3022 case EXTERNAL_FLOAT_ELEMENTS: | 3023 case EXTERNAL_FLOAT_ELEMENTS: |
3023 // Ignore getters and setters on pixel and external array | 3024 // Ignore getters and setters on pixel and external array |
3024 // elements. | 3025 // elements. |
3025 return Heap::undefined_value(); | 3026 return Heap::undefined_value(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3229 uint32_t index = 0; | 3230 uint32_t index = 0; |
3230 bool is_element = name->AsArrayIndex(&index); | 3231 bool is_element = name->AsArrayIndex(&index); |
3231 | 3232 |
3232 if (is_element) { | 3233 if (is_element) { |
3233 if (IsJSArray()) return Heap::undefined_value(); | 3234 if (IsJSArray()) return Heap::undefined_value(); |
3234 | 3235 |
3235 // Accessors overwrite previous callbacks (cf. with getters/setters). | 3236 // Accessors overwrite previous callbacks (cf. with getters/setters). |
3236 switch (GetElementsKind()) { | 3237 switch (GetElementsKind()) { |
3237 case FAST_ELEMENTS: | 3238 case FAST_ELEMENTS: |
3238 break; | 3239 break; |
3239 case PIXEL_ELEMENTS: | 3240 case EXTERNAL_PIXEL_ELEMENTS: |
3240 case EXTERNAL_BYTE_ELEMENTS: | 3241 case EXTERNAL_BYTE_ELEMENTS: |
3241 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3242 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3242 case EXTERNAL_SHORT_ELEMENTS: | 3243 case EXTERNAL_SHORT_ELEMENTS: |
3243 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3244 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3244 case EXTERNAL_INT_ELEMENTS: | 3245 case EXTERNAL_INT_ELEMENTS: |
3245 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3246 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3246 case EXTERNAL_FLOAT_ELEMENTS: | 3247 case EXTERNAL_FLOAT_ELEMENTS: |
3247 // Ignore getters and setters on pixel and external array | 3248 // Ignore getters and setters on pixel and external array |
3248 // elements. | 3249 // elements. |
3249 return Heap::undefined_value(); | 3250 return Heap::undefined_value(); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3810 if (element->IsString() && | 3811 if (element->IsString() && |
3811 key->IsString() && String::cast(element)->Equals(String::cast(key))) { | 3812 key->IsString() && String::cast(element)->Equals(String::cast(key))) { |
3812 return true; | 3813 return true; |
3813 } | 3814 } |
3814 } | 3815 } |
3815 return false; | 3816 return false; |
3816 } | 3817 } |
3817 | 3818 |
3818 | 3819 |
3819 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 3820 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
3820 ASSERT(!array->HasPixelElements() && !array->HasExternalArrayElements()); | 3821 ASSERT(!array->HasExternalArrayElements()); |
3821 switch (array->GetElementsKind()) { | 3822 switch (array->GetElementsKind()) { |
3822 case JSObject::FAST_ELEMENTS: | 3823 case JSObject::FAST_ELEMENTS: |
3823 return UnionOfKeys(FixedArray::cast(array->elements())); | 3824 return UnionOfKeys(FixedArray::cast(array->elements())); |
3824 case JSObject::DICTIONARY_ELEMENTS: { | 3825 case JSObject::DICTIONARY_ELEMENTS: { |
3825 NumberDictionary* dict = array->element_dictionary(); | 3826 NumberDictionary* dict = array->element_dictionary(); |
3826 int size = dict->NumberOfElements(); | 3827 int size = dict->NumberOfElements(); |
3827 | 3828 |
3828 // Allocate a temporary fixed array. | 3829 // Allocate a temporary fixed array. |
3829 Object* object; | 3830 Object* object; |
3830 { MaybeObject* maybe_object = Heap::AllocateFixedArray(size); | 3831 { MaybeObject* maybe_object = Heap::AllocateFixedArray(size); |
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6248 | 6249 |
6249 // Identify kind of code. | 6250 // Identify kind of code. |
6250 const char* Code::Kind2String(Kind kind) { | 6251 const char* Code::Kind2String(Kind kind) { |
6251 switch (kind) { | 6252 switch (kind) { |
6252 case FUNCTION: return "FUNCTION"; | 6253 case FUNCTION: return "FUNCTION"; |
6253 case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION"; | 6254 case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION"; |
6254 case STUB: return "STUB"; | 6255 case STUB: return "STUB"; |
6255 case BUILTIN: return "BUILTIN"; | 6256 case BUILTIN: return "BUILTIN"; |
6256 case LOAD_IC: return "LOAD_IC"; | 6257 case LOAD_IC: return "LOAD_IC"; |
6257 case KEYED_LOAD_IC: return "KEYED_LOAD_IC"; | 6258 case KEYED_LOAD_IC: return "KEYED_LOAD_IC"; |
| 6259 case KEYED_EXTERNAL_ARRAY_LOAD_IC: return "KEYED_EXTERNAL_ARRAY_LOAD_IC"; |
6258 case STORE_IC: return "STORE_IC"; | 6260 case STORE_IC: return "STORE_IC"; |
6259 case KEYED_STORE_IC: return "KEYED_STORE_IC"; | 6261 case KEYED_STORE_IC: return "KEYED_STORE_IC"; |
| 6262 case KEYED_EXTERNAL_ARRAY_STORE_IC: return "KEYED_EXTERNAL_ARRAY_STORE_IC"; |
6260 case CALL_IC: return "CALL_IC"; | 6263 case CALL_IC: return "CALL_IC"; |
6261 case KEYED_CALL_IC: return "KEYED_CALL_IC"; | 6264 case KEYED_CALL_IC: return "KEYED_CALL_IC"; |
6262 case BINARY_OP_IC: return "BINARY_OP_IC"; | 6265 case BINARY_OP_IC: return "BINARY_OP_IC"; |
6263 case TYPE_RECORDING_BINARY_OP_IC: return "TYPE_RECORDING_BINARY_OP_IC"; | 6266 case TYPE_RECORDING_BINARY_OP_IC: return "TYPE_RECORDING_BINARY_OP_IC"; |
6264 case COMPARE_IC: return "COMPARE_IC"; | 6267 case COMPARE_IC: return "COMPARE_IC"; |
6265 } | 6268 } |
6266 UNREACHABLE(); | 6269 UNREACHABLE(); |
6267 return NULL; | 6270 return NULL; |
6268 } | 6271 } |
6269 | 6272 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6399 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 6402 PrintF("RelocInfo (size = %d)\n", relocation_size()); |
6400 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); | 6403 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); |
6401 PrintF(out, "\n"); | 6404 PrintF(out, "\n"); |
6402 } | 6405 } |
6403 #endif // ENABLE_DISASSEMBLER | 6406 #endif // ENABLE_DISASSEMBLER |
6404 | 6407 |
6405 | 6408 |
6406 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, | 6409 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, |
6407 int length) { | 6410 int length) { |
6408 // We should never end in here with a pixel or external array. | 6411 // We should never end in here with a pixel or external array. |
6409 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 6412 ASSERT(!HasExternalArrayElements()); |
6410 | 6413 |
6411 Object* obj; | 6414 Object* obj; |
6412 { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity); | 6415 { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity); |
6413 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6416 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6414 } | 6417 } |
6415 FixedArray* elems = FixedArray::cast(obj); | 6418 FixedArray* elems = FixedArray::cast(obj); |
6416 | 6419 |
6417 { MaybeObject* maybe_obj = map()->GetFastElementsMap(); | 6420 { MaybeObject* maybe_obj = map()->GetFastElementsMap(); |
6418 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6421 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6419 } | 6422 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6453 if (IsJSArray()) { | 6456 if (IsJSArray()) { |
6454 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 6457 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
6455 } | 6458 } |
6456 | 6459 |
6457 return this; | 6460 return this; |
6458 } | 6461 } |
6459 | 6462 |
6460 | 6463 |
6461 MaybeObject* JSObject::SetSlowElements(Object* len) { | 6464 MaybeObject* JSObject::SetSlowElements(Object* len) { |
6462 // We should never end in here with a pixel or external array. | 6465 // We should never end in here with a pixel or external array. |
6463 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 6466 ASSERT(!HasExternalArrayElements()); |
6464 | 6467 |
6465 uint32_t new_length = static_cast<uint32_t>(len->Number()); | 6468 uint32_t new_length = static_cast<uint32_t>(len->Number()); |
6466 | 6469 |
6467 switch (GetElementsKind()) { | 6470 switch (GetElementsKind()) { |
6468 case FAST_ELEMENTS: { | 6471 case FAST_ELEMENTS: { |
6469 // Make sure we never try to shrink dense arrays into sparse arrays. | 6472 // Make sure we never try to shrink dense arrays into sparse arrays. |
6470 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= | 6473 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= |
6471 new_length); | 6474 new_length); |
6472 Object* obj; | 6475 Object* obj; |
6473 { MaybeObject* maybe_obj = NormalizeElements(); | 6476 { MaybeObject* maybe_obj = NormalizeElements(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6675 uint32_t length = IsJSArray() ? | 6678 uint32_t length = IsJSArray() ? |
6676 static_cast<uint32_t> | 6679 static_cast<uint32_t> |
6677 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6680 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6678 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6681 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6679 if ((index < length) && | 6682 if ((index < length) && |
6680 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | 6683 !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
6681 return true; | 6684 return true; |
6682 } | 6685 } |
6683 break; | 6686 break; |
6684 } | 6687 } |
6685 case PIXEL_ELEMENTS: { | 6688 case EXTERNAL_PIXEL_ELEMENTS: { |
6686 PixelArray* pixels = PixelArray::cast(elements()); | 6689 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6687 if (index < static_cast<uint32_t>(pixels->length())) { | 6690 if (index < static_cast<uint32_t>(pixels->length())) { |
6688 return true; | 6691 return true; |
6689 } | 6692 } |
6690 break; | 6693 break; |
6691 } | 6694 } |
6692 case EXTERNAL_BYTE_ELEMENTS: | 6695 case EXTERNAL_BYTE_ELEMENTS: |
6693 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6696 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6694 case EXTERNAL_SHORT_ELEMENTS: | 6697 case EXTERNAL_SHORT_ELEMENTS: |
6695 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6698 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6696 case EXTERNAL_INT_ELEMENTS: | 6699 case EXTERNAL_INT_ELEMENTS: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6794 uint32_t length = IsJSArray() ? | 6797 uint32_t length = IsJSArray() ? |
6795 static_cast<uint32_t> | 6798 static_cast<uint32_t> |
6796 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6799 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6797 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6800 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6798 if ((index < length) && | 6801 if ((index < length) && |
6799 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | 6802 !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
6800 return FAST_ELEMENT; | 6803 return FAST_ELEMENT; |
6801 } | 6804 } |
6802 break; | 6805 break; |
6803 } | 6806 } |
6804 case PIXEL_ELEMENTS: { | 6807 case EXTERNAL_PIXEL_ELEMENTS: { |
6805 PixelArray* pixels = PixelArray::cast(elements()); | 6808 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6806 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; | 6809 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; |
6807 break; | 6810 break; |
6808 } | 6811 } |
6809 case EXTERNAL_BYTE_ELEMENTS: | 6812 case EXTERNAL_BYTE_ELEMENTS: |
6810 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6813 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6811 case EXTERNAL_SHORT_ELEMENTS: | 6814 case EXTERNAL_SHORT_ELEMENTS: |
6812 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6815 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6813 case EXTERNAL_INT_ELEMENTS: | 6816 case EXTERNAL_INT_ELEMENTS: |
6814 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 6817 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
6815 case EXTERNAL_FLOAT_ELEMENTS: { | 6818 case EXTERNAL_FLOAT_ELEMENTS: { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6849 switch (GetElementsKind()) { | 6852 switch (GetElementsKind()) { |
6850 case FAST_ELEMENTS: { | 6853 case FAST_ELEMENTS: { |
6851 uint32_t length = IsJSArray() ? | 6854 uint32_t length = IsJSArray() ? |
6852 static_cast<uint32_t> | 6855 static_cast<uint32_t> |
6853 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6856 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6854 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6857 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6855 if ((index < length) && | 6858 if ((index < length) && |
6856 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; | 6859 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; |
6857 break; | 6860 break; |
6858 } | 6861 } |
6859 case PIXEL_ELEMENTS: { | 6862 case EXTERNAL_PIXEL_ELEMENTS: { |
6860 PixelArray* pixels = PixelArray::cast(elements()); | 6863 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6861 if (index < static_cast<uint32_t>(pixels->length())) { | 6864 if (index < static_cast<uint32_t>(pixels->length())) { |
6862 return true; | 6865 return true; |
6863 } | 6866 } |
6864 break; | 6867 break; |
6865 } | 6868 } |
6866 case EXTERNAL_BYTE_ELEMENTS: | 6869 case EXTERNAL_BYTE_ELEMENTS: |
6867 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6870 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6868 case EXTERNAL_SHORT_ELEMENTS: | 6871 case EXTERNAL_SHORT_ELEMENTS: |
6869 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6872 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6870 case EXTERNAL_INT_ELEMENTS: | 6873 case EXTERNAL_INT_ELEMENTS: |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7140 | 7143 |
7141 | 7144 |
7142 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, | 7145 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, |
7143 Object* value, | 7146 Object* value, |
7144 StrictModeFlag strict_mode, | 7147 StrictModeFlag strict_mode, |
7145 bool check_prototype) { | 7148 bool check_prototype) { |
7146 switch (GetElementsKind()) { | 7149 switch (GetElementsKind()) { |
7147 case FAST_ELEMENTS: | 7150 case FAST_ELEMENTS: |
7148 // Fast case. | 7151 // Fast case. |
7149 return SetFastElement(index, value, strict_mode, check_prototype); | 7152 return SetFastElement(index, value, strict_mode, check_prototype); |
7150 case PIXEL_ELEMENTS: { | 7153 case EXTERNAL_PIXEL_ELEMENTS: { |
7151 PixelArray* pixels = PixelArray::cast(elements()); | 7154 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7152 return pixels->SetValue(index, value); | 7155 return pixels->SetValue(index, value); |
7153 } | 7156 } |
7154 case EXTERNAL_BYTE_ELEMENTS: { | 7157 case EXTERNAL_BYTE_ELEMENTS: { |
7155 ExternalByteArray* array = ExternalByteArray::cast(elements()); | 7158 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
7156 return array->SetValue(index, value); | 7159 return array->SetValue(index, value); |
7157 } | 7160 } |
7158 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 7161 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
7159 ExternalUnsignedByteArray* array = | 7162 ExternalUnsignedByteArray* array = |
7160 ExternalUnsignedByteArray::cast(elements()); | 7163 ExternalUnsignedByteArray::cast(elements()); |
7161 return array->SetValue(index, value); | 7164 return array->SetValue(index, value); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7303 // JSArray::length cannot change. | 7306 // JSArray::length cannot change. |
7304 switch (GetElementsKind()) { | 7307 switch (GetElementsKind()) { |
7305 case FAST_ELEMENTS: { | 7308 case FAST_ELEMENTS: { |
7306 FixedArray* elms = FixedArray::cast(elements()); | 7309 FixedArray* elms = FixedArray::cast(elements()); |
7307 if (index < static_cast<uint32_t>(elms->length())) { | 7310 if (index < static_cast<uint32_t>(elms->length())) { |
7308 Object* value = elms->get(index); | 7311 Object* value = elms->get(index); |
7309 if (!value->IsTheHole()) return value; | 7312 if (!value->IsTheHole()) return value; |
7310 } | 7313 } |
7311 break; | 7314 break; |
7312 } | 7315 } |
7313 case PIXEL_ELEMENTS: | 7316 case EXTERNAL_PIXEL_ELEMENTS: |
7314 case EXTERNAL_BYTE_ELEMENTS: | 7317 case EXTERNAL_BYTE_ELEMENTS: |
7315 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7318 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7316 case EXTERNAL_SHORT_ELEMENTS: | 7319 case EXTERNAL_SHORT_ELEMENTS: |
7317 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7320 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7318 case EXTERNAL_INT_ELEMENTS: | 7321 case EXTERNAL_INT_ELEMENTS: |
7319 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7322 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7320 case EXTERNAL_FLOAT_ELEMENTS: { | 7323 case EXTERNAL_FLOAT_ELEMENTS: { |
7321 MaybeObject* maybe_value = GetExternalElement(index); | 7324 MaybeObject* maybe_value = GetExternalElement(index); |
7322 Object* value; | 7325 Object* value; |
7323 if (!maybe_value->ToObject(&value)) return maybe_value; | 7326 if (!maybe_value->ToObject(&value)) return maybe_value; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7402 // JSArray::length cannot change. | 7405 // JSArray::length cannot change. |
7403 switch (GetElementsKind()) { | 7406 switch (GetElementsKind()) { |
7404 case FAST_ELEMENTS: { | 7407 case FAST_ELEMENTS: { |
7405 FixedArray* elms = FixedArray::cast(elements()); | 7408 FixedArray* elms = FixedArray::cast(elements()); |
7406 if (index < static_cast<uint32_t>(elms->length())) { | 7409 if (index < static_cast<uint32_t>(elms->length())) { |
7407 Object* value = elms->get(index); | 7410 Object* value = elms->get(index); |
7408 if (!value->IsTheHole()) return value; | 7411 if (!value->IsTheHole()) return value; |
7409 } | 7412 } |
7410 break; | 7413 break; |
7411 } | 7414 } |
7412 case PIXEL_ELEMENTS: | 7415 case EXTERNAL_PIXEL_ELEMENTS: |
7413 case EXTERNAL_BYTE_ELEMENTS: | 7416 case EXTERNAL_BYTE_ELEMENTS: |
7414 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7417 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7415 case EXTERNAL_SHORT_ELEMENTS: | 7418 case EXTERNAL_SHORT_ELEMENTS: |
7416 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7419 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7417 case EXTERNAL_INT_ELEMENTS: | 7420 case EXTERNAL_INT_ELEMENTS: |
7418 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7421 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7419 case EXTERNAL_FLOAT_ELEMENTS: { | 7422 case EXTERNAL_FLOAT_ELEMENTS: { |
7420 MaybeObject* maybe_value = GetExternalElement(index); | 7423 MaybeObject* maybe_value = GetExternalElement(index); |
7421 Object* value; | 7424 Object* value; |
7422 if (!maybe_value->ToObject(&value)) return maybe_value; | 7425 if (!maybe_value->ToObject(&value)) return maybe_value; |
(...skipping 21 matching lines...) Expand all Loading... |
7444 Object* pt = GetPrototype(); | 7447 Object* pt = GetPrototype(); |
7445 if (pt == Heap::null_value()) return Heap::undefined_value(); | 7448 if (pt == Heap::null_value()) return Heap::undefined_value(); |
7446 return pt->GetElementWithReceiver(receiver, index); | 7449 return pt->GetElementWithReceiver(receiver, index); |
7447 } | 7450 } |
7448 | 7451 |
7449 | 7452 |
7450 MaybeObject* JSObject::GetExternalElement(uint32_t index) { | 7453 MaybeObject* JSObject::GetExternalElement(uint32_t index) { |
7451 // Get element works for both JSObject and JSArray since | 7454 // Get element works for both JSObject and JSArray since |
7452 // JSArray::length cannot change. | 7455 // JSArray::length cannot change. |
7453 switch (GetElementsKind()) { | 7456 switch (GetElementsKind()) { |
7454 case PIXEL_ELEMENTS: { | 7457 case EXTERNAL_PIXEL_ELEMENTS: { |
7455 PixelArray* pixels = PixelArray::cast(elements()); | 7458 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7456 if (index < static_cast<uint32_t>(pixels->length())) { | 7459 if (index < static_cast<uint32_t>(pixels->length())) { |
7457 uint8_t value = pixels->get(index); | 7460 uint8_t value = pixels->get(index); |
7458 return Smi::FromInt(value); | 7461 return Smi::FromInt(value); |
7459 } | 7462 } |
7460 break; | 7463 break; |
7461 } | 7464 } |
7462 case EXTERNAL_BYTE_ELEMENTS: { | 7465 case EXTERNAL_BYTE_ELEMENTS: { |
7463 ExternalByteArray* array = ExternalByteArray::cast(elements()); | 7466 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
7464 if (index < static_cast<uint32_t>(array->length())) { | 7467 if (index < static_cast<uint32_t>(array->length())) { |
7465 int8_t value = array->get(index); | 7468 int8_t value = array->get(index); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7533 | 7536 |
7534 switch (GetElementsKind()) { | 7537 switch (GetElementsKind()) { |
7535 case FAST_ELEMENTS: { | 7538 case FAST_ELEMENTS: { |
7536 FixedArray* elms = FixedArray::cast(elements()); | 7539 FixedArray* elms = FixedArray::cast(elements()); |
7537 capacity = elms->length(); | 7540 capacity = elms->length(); |
7538 for (int i = 0; i < capacity; i++) { | 7541 for (int i = 0; i < capacity; i++) { |
7539 if (!elms->get(i)->IsTheHole()) number_of_elements++; | 7542 if (!elms->get(i)->IsTheHole()) number_of_elements++; |
7540 } | 7543 } |
7541 break; | 7544 break; |
7542 } | 7545 } |
7543 case PIXEL_ELEMENTS: | 7546 case EXTERNAL_PIXEL_ELEMENTS: |
7544 case EXTERNAL_BYTE_ELEMENTS: | 7547 case EXTERNAL_BYTE_ELEMENTS: |
7545 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7548 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7546 case EXTERNAL_SHORT_ELEMENTS: | 7549 case EXTERNAL_SHORT_ELEMENTS: |
7547 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7550 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7548 case EXTERNAL_INT_ELEMENTS: | 7551 case EXTERNAL_INT_ELEMENTS: |
7549 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7552 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7550 case EXTERNAL_FLOAT_ELEMENTS: { | 7553 case EXTERNAL_FLOAT_ELEMENTS: { |
7551 return true; | 7554 return true; |
7552 } | 7555 } |
7553 case DICTIONARY_ELEMENTS: { | 7556 case DICTIONARY_ELEMENTS: { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7761 | 7764 |
7762 switch (GetElementsKind()) { | 7765 switch (GetElementsKind()) { |
7763 case FAST_ELEMENTS: { | 7766 case FAST_ELEMENTS: { |
7764 uint32_t length = IsJSArray() ? | 7767 uint32_t length = IsJSArray() ? |
7765 static_cast<uint32_t>( | 7768 static_cast<uint32_t>( |
7766 Smi::cast(JSArray::cast(this)->length())->value()) : | 7769 Smi::cast(JSArray::cast(this)->length())->value()) : |
7767 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 7770 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
7768 return (index < length) && | 7771 return (index < length) && |
7769 !FixedArray::cast(elements())->get(index)->IsTheHole(); | 7772 !FixedArray::cast(elements())->get(index)->IsTheHole(); |
7770 } | 7773 } |
7771 case PIXEL_ELEMENTS: { | 7774 case EXTERNAL_PIXEL_ELEMENTS: { |
7772 PixelArray* pixels = PixelArray::cast(elements()); | 7775 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7773 return index < static_cast<uint32_t>(pixels->length()); | 7776 return index < static_cast<uint32_t>(pixels->length()); |
7774 } | 7777 } |
7775 case EXTERNAL_BYTE_ELEMENTS: | 7778 case EXTERNAL_BYTE_ELEMENTS: |
7776 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7779 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7777 case EXTERNAL_SHORT_ELEMENTS: | 7780 case EXTERNAL_SHORT_ELEMENTS: |
7778 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7781 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7779 case EXTERNAL_INT_ELEMENTS: | 7782 case EXTERNAL_INT_ELEMENTS: |
7780 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7783 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7781 case EXTERNAL_FLOAT_ELEMENTS: { | 7784 case EXTERNAL_FLOAT_ELEMENTS: { |
7782 ExternalArray* array = ExternalArray::cast(elements()); | 7785 ExternalArray* array = ExternalArray::cast(elements()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7993 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { | 7996 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { |
7994 if (storage != NULL) { | 7997 if (storage != NULL) { |
7995 storage->set(counter, Smi::FromInt(i)); | 7998 storage->set(counter, Smi::FromInt(i)); |
7996 } | 7999 } |
7997 counter++; | 8000 counter++; |
7998 } | 8001 } |
7999 } | 8002 } |
8000 ASSERT(!storage || storage->length() >= counter); | 8003 ASSERT(!storage || storage->length() >= counter); |
8001 break; | 8004 break; |
8002 } | 8005 } |
8003 case PIXEL_ELEMENTS: { | 8006 case EXTERNAL_PIXEL_ELEMENTS: { |
8004 int length = PixelArray::cast(elements())->length(); | 8007 int length = ExternalPixelArray::cast(elements())->length(); |
8005 while (counter < length) { | 8008 while (counter < length) { |
8006 if (storage != NULL) { | 8009 if (storage != NULL) { |
8007 storage->set(counter, Smi::FromInt(counter)); | 8010 storage->set(counter, Smi::FromInt(counter)); |
8008 } | 8011 } |
8009 counter++; | 8012 counter++; |
8010 } | 8013 } |
8011 ASSERT(!storage || storage->length() >= counter); | 8014 ASSERT(!storage || storage->length() >= counter); |
8012 break; | 8015 break; |
8013 } | 8016 } |
8014 case EXTERNAL_BYTE_ELEMENTS: | 8017 case EXTERNAL_BYTE_ELEMENTS: |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8735 result_double->set_value(static_cast<double>(result)); | 8738 result_double->set_value(static_cast<double>(result)); |
8736 return result_double; | 8739 return result_double; |
8737 } | 8740 } |
8738 | 8741 |
8739 | 8742 |
8740 // Collects all defined (non-hole) and non-undefined (array) elements at | 8743 // Collects all defined (non-hole) and non-undefined (array) elements at |
8741 // the start of the elements array. | 8744 // the start of the elements array. |
8742 // If the object is in dictionary mode, it is converted to fast elements | 8745 // If the object is in dictionary mode, it is converted to fast elements |
8743 // mode. | 8746 // mode. |
8744 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { | 8747 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { |
8745 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 8748 ASSERT(!HasExternalArrayElements()); |
8746 | 8749 |
8747 if (HasDictionaryElements()) { | 8750 if (HasDictionaryElements()) { |
8748 // Convert to fast elements containing only the existing properties. | 8751 // Convert to fast elements containing only the existing properties. |
8749 // Ordering is irrelevant, since we are going to sort anyway. | 8752 // Ordering is irrelevant, since we are going to sort anyway. |
8750 NumberDictionary* dict = element_dictionary(); | 8753 NumberDictionary* dict = element_dictionary(); |
8751 if (IsJSArray() || dict->requires_slow_elements() || | 8754 if (IsJSArray() || dict->requires_slow_elements() || |
8752 dict->max_number_key() >= limit) { | 8755 dict->max_number_key() >= limit) { |
8753 return PrepareSlowElementsForSort(limit); | 8756 return PrepareSlowElementsForSort(limit); |
8754 } | 8757 } |
8755 // Convert to fast elements. | 8758 // Convert to fast elements. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8847 | 8850 |
8848 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { | 8851 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { |
8849 return Smi::FromInt(static_cast<int>(result)); | 8852 return Smi::FromInt(static_cast<int>(result)); |
8850 } | 8853 } |
8851 ASSERT_NE(NULL, result_double); | 8854 ASSERT_NE(NULL, result_double); |
8852 result_double->set_value(static_cast<double>(result)); | 8855 result_double->set_value(static_cast<double>(result)); |
8853 return result_double; | 8856 return result_double; |
8854 } | 8857 } |
8855 | 8858 |
8856 | 8859 |
8857 Object* PixelArray::SetValue(uint32_t index, Object* value) { | 8860 Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { |
8858 uint8_t clamped_value = 0; | 8861 uint8_t clamped_value = 0; |
8859 if (index < static_cast<uint32_t>(length())) { | 8862 if (index < static_cast<uint32_t>(length())) { |
8860 if (value->IsSmi()) { | 8863 if (value->IsSmi()) { |
8861 int int_value = Smi::cast(value)->value(); | 8864 int int_value = Smi::cast(value)->value(); |
8862 if (int_value < 0) { | 8865 if (int_value < 0) { |
8863 clamped_value = 0; | 8866 clamped_value = 0; |
8864 } else if (int_value > 255) { | 8867 } else if (int_value > 255) { |
8865 clamped_value = 255; | 8868 clamped_value = 255; |
8866 } else { | 8869 } else { |
8867 clamped_value = static_cast<uint8_t>(int_value); | 8870 clamped_value = static_cast<uint8_t>(int_value); |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10055 if (break_point_objects()->IsUndefined()) return 0; | 10058 if (break_point_objects()->IsUndefined()) return 0; |
10056 // Single beak point. | 10059 // Single beak point. |
10057 if (!break_point_objects()->IsFixedArray()) return 1; | 10060 if (!break_point_objects()->IsFixedArray()) return 1; |
10058 // Multiple break points. | 10061 // Multiple break points. |
10059 return FixedArray::cast(break_point_objects())->length(); | 10062 return FixedArray::cast(break_point_objects())->length(); |
10060 } | 10063 } |
10061 #endif | 10064 #endif |
10062 | 10065 |
10063 | 10066 |
10064 } } // namespace v8::internal | 10067 } } // namespace v8::internal |
OLD | NEW |