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 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2412 | 2413 |
2413 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { | 2414 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { |
2414 if (HasFastProperties()) return this; | 2415 if (HasFastProperties()) return this; |
2415 ASSERT(!IsGlobalObject()); | 2416 ASSERT(!IsGlobalObject()); |
2416 return property_dictionary()-> | 2417 return property_dictionary()-> |
2417 TransformPropertiesToFastFor(this, unused_property_fields); | 2418 TransformPropertiesToFastFor(this, unused_property_fields); |
2418 } | 2419 } |
2419 | 2420 |
2420 | 2421 |
2421 MaybeObject* JSObject::NormalizeElements() { | 2422 MaybeObject* JSObject::NormalizeElements() { |
2422 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 2423 ASSERT(!HasExternalArrayElements()); |
2423 if (HasDictionaryElements()) return this; | 2424 if (HasDictionaryElements()) return this; |
2424 ASSERT(map()->has_fast_elements()); | 2425 ASSERT(map()->has_fast_elements()); |
2425 | 2426 |
2426 Object* obj; | 2427 Object* obj; |
2427 { MaybeObject* maybe_obj = map()->GetSlowElementsMap(); | 2428 { MaybeObject* maybe_obj = map()->GetSlowElementsMap(); |
2428 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2429 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2429 } | 2430 } |
2430 Map* new_map = Map::cast(obj); | 2431 Map* new_map = Map::cast(obj); |
2431 | 2432 |
2432 // Get number of entries. | 2433 // Get number of entries. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2514 } | 2515 } |
2515 MaybeObject* raw_result = | 2516 MaybeObject* raw_result = |
2516 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); | 2517 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); |
2517 RETURN_IF_SCHEDULED_EXCEPTION(); | 2518 RETURN_IF_SCHEDULED_EXCEPTION(); |
2518 return raw_result; | 2519 return raw_result; |
2519 } | 2520 } |
2520 | 2521 |
2521 | 2522 |
2522 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, | 2523 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, |
2523 DeleteMode mode) { | 2524 DeleteMode mode) { |
2524 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 2525 ASSERT(!HasExternalArrayElements()); |
2525 switch (GetElementsKind()) { | 2526 switch (GetElementsKind()) { |
2526 case FAST_ELEMENTS: { | 2527 case FAST_ELEMENTS: { |
2527 Object* obj; | 2528 Object* obj; |
2528 { MaybeObject* maybe_obj = EnsureWritableFastElements(); | 2529 { MaybeObject* maybe_obj = EnsureWritableFastElements(); |
2529 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2530 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2530 } | 2531 } |
2531 uint32_t length = IsJSArray() ? | 2532 uint32_t length = IsJSArray() ? |
2532 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2533 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2533 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2534 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2534 if (index < length) { | 2535 if (index < length) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2613 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2614 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2614 } | 2615 } |
2615 uint32_t length = IsJSArray() ? | 2616 uint32_t length = IsJSArray() ? |
2616 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2617 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2617 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2618 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2618 if (index < length) { | 2619 if (index < length) { |
2619 FixedArray::cast(elements())->set_the_hole(index); | 2620 FixedArray::cast(elements())->set_the_hole(index); |
2620 } | 2621 } |
2621 break; | 2622 break; |
2622 } | 2623 } |
2623 case PIXEL_ELEMENTS: | 2624 case EXTERNAL_PIXEL_ELEMENTS: |
2624 case EXTERNAL_BYTE_ELEMENTS: | 2625 case EXTERNAL_BYTE_ELEMENTS: |
2625 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2626 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2626 case EXTERNAL_SHORT_ELEMENTS: | 2627 case EXTERNAL_SHORT_ELEMENTS: |
2627 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2628 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2628 case EXTERNAL_INT_ELEMENTS: | 2629 case EXTERNAL_INT_ELEMENTS: |
2629 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2630 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2630 case EXTERNAL_FLOAT_ELEMENTS: | 2631 case EXTERNAL_FLOAT_ELEMENTS: |
2631 // Pixel and external array elements cannot be deleted. Just | 2632 // Pixel and external array elements cannot be deleted. Just |
2632 // silently ignore here. | 2633 // silently ignore here. |
2633 break; | 2634 break; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2728 } | 2729 } |
2729 | 2730 |
2730 // Check if the object is among the named properties. | 2731 // Check if the object is among the named properties. |
2731 Object* key = SlowReverseLookup(obj); | 2732 Object* key = SlowReverseLookup(obj); |
2732 if (key != Heap::undefined_value()) { | 2733 if (key != Heap::undefined_value()) { |
2733 return true; | 2734 return true; |
2734 } | 2735 } |
2735 | 2736 |
2736 // Check if the object is among the indexed properties. | 2737 // Check if the object is among the indexed properties. |
2737 switch (GetElementsKind()) { | 2738 switch (GetElementsKind()) { |
2738 case PIXEL_ELEMENTS: | 2739 case EXTERNAL_PIXEL_ELEMENTS: |
2739 case EXTERNAL_BYTE_ELEMENTS: | 2740 case EXTERNAL_BYTE_ELEMENTS: |
2740 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2741 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2741 case EXTERNAL_SHORT_ELEMENTS: | 2742 case EXTERNAL_SHORT_ELEMENTS: |
2742 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2743 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2743 case EXTERNAL_INT_ELEMENTS: | 2744 case EXTERNAL_INT_ELEMENTS: |
2744 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2745 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2745 case EXTERNAL_FLOAT_ELEMENTS: | 2746 case EXTERNAL_FLOAT_ELEMENTS: |
2746 // Raw pixels and external arrays do not reference other | 2747 // Raw pixels and external arrays do not reference other |
2747 // objects. | 2748 // objects. |
2748 break; | 2749 break; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2982 return Heap::undefined_value(); | 2983 return Heap::undefined_value(); |
2983 } | 2984 } |
2984 | 2985 |
2985 uint32_t index = 0; | 2986 uint32_t index = 0; |
2986 bool is_element = name->AsArrayIndex(&index); | 2987 bool is_element = name->AsArrayIndex(&index); |
2987 | 2988 |
2988 if (is_element) { | 2989 if (is_element) { |
2989 switch (GetElementsKind()) { | 2990 switch (GetElementsKind()) { |
2990 case FAST_ELEMENTS: | 2991 case FAST_ELEMENTS: |
2991 break; | 2992 break; |
2992 case PIXEL_ELEMENTS: | 2993 case EXTERNAL_PIXEL_ELEMENTS: |
2993 case EXTERNAL_BYTE_ELEMENTS: | 2994 case EXTERNAL_BYTE_ELEMENTS: |
2994 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2995 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2995 case EXTERNAL_SHORT_ELEMENTS: | 2996 case EXTERNAL_SHORT_ELEMENTS: |
2996 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2997 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2997 case EXTERNAL_INT_ELEMENTS: | 2998 case EXTERNAL_INT_ELEMENTS: |
2998 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2999 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2999 case EXTERNAL_FLOAT_ELEMENTS: | 3000 case EXTERNAL_FLOAT_ELEMENTS: |
3000 // Ignore getters and setters on pixel and external array | 3001 // Ignore getters and setters on pixel and external array |
3001 // elements. | 3002 // elements. |
3002 return Heap::undefined_value(); | 3003 return Heap::undefined_value(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3206 uint32_t index = 0; | 3207 uint32_t index = 0; |
3207 bool is_element = name->AsArrayIndex(&index); | 3208 bool is_element = name->AsArrayIndex(&index); |
3208 | 3209 |
3209 if (is_element) { | 3210 if (is_element) { |
3210 if (IsJSArray()) return Heap::undefined_value(); | 3211 if (IsJSArray()) return Heap::undefined_value(); |
3211 | 3212 |
3212 // Accessors overwrite previous callbacks (cf. with getters/setters). | 3213 // Accessors overwrite previous callbacks (cf. with getters/setters). |
3213 switch (GetElementsKind()) { | 3214 switch (GetElementsKind()) { |
3214 case FAST_ELEMENTS: | 3215 case FAST_ELEMENTS: |
3215 break; | 3216 break; |
3216 case PIXEL_ELEMENTS: | 3217 case EXTERNAL_PIXEL_ELEMENTS: |
3217 case EXTERNAL_BYTE_ELEMENTS: | 3218 case EXTERNAL_BYTE_ELEMENTS: |
3218 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3219 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3219 case EXTERNAL_SHORT_ELEMENTS: | 3220 case EXTERNAL_SHORT_ELEMENTS: |
3220 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3221 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3221 case EXTERNAL_INT_ELEMENTS: | 3222 case EXTERNAL_INT_ELEMENTS: |
3222 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3223 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3223 case EXTERNAL_FLOAT_ELEMENTS: | 3224 case EXTERNAL_FLOAT_ELEMENTS: |
3224 // Ignore getters and setters on pixel and external array | 3225 // Ignore getters and setters on pixel and external array |
3225 // elements. | 3226 // elements. |
3226 return Heap::undefined_value(); | 3227 return Heap::undefined_value(); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3787 if (element->IsString() && | 3788 if (element->IsString() && |
3788 key->IsString() && String::cast(element)->Equals(String::cast(key))) { | 3789 key->IsString() && String::cast(element)->Equals(String::cast(key))) { |
3789 return true; | 3790 return true; |
3790 } | 3791 } |
3791 } | 3792 } |
3792 return false; | 3793 return false; |
3793 } | 3794 } |
3794 | 3795 |
3795 | 3796 |
3796 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 3797 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
3797 ASSERT(!array->HasPixelElements() && !array->HasExternalArrayElements()); | 3798 ASSERT(!array->HasExternalArrayElements()); |
3798 switch (array->GetElementsKind()) { | 3799 switch (array->GetElementsKind()) { |
3799 case JSObject::FAST_ELEMENTS: | 3800 case JSObject::FAST_ELEMENTS: |
3800 return UnionOfKeys(FixedArray::cast(array->elements())); | 3801 return UnionOfKeys(FixedArray::cast(array->elements())); |
3801 case JSObject::DICTIONARY_ELEMENTS: { | 3802 case JSObject::DICTIONARY_ELEMENTS: { |
3802 NumberDictionary* dict = array->element_dictionary(); | 3803 NumberDictionary* dict = array->element_dictionary(); |
3803 int size = dict->NumberOfElements(); | 3804 int size = dict->NumberOfElements(); |
3804 | 3805 |
3805 // Allocate a temporary fixed array. | 3806 // Allocate a temporary fixed array. |
3806 Object* object; | 3807 Object* object; |
3807 { MaybeObject* maybe_object = Heap::AllocateFixedArray(size); | 3808 { MaybeObject* maybe_object = Heap::AllocateFixedArray(size); |
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6219 | 6220 |
6220 // Identify kind of code. | 6221 // Identify kind of code. |
6221 const char* Code::Kind2String(Kind kind) { | 6222 const char* Code::Kind2String(Kind kind) { |
6222 switch (kind) { | 6223 switch (kind) { |
6223 case FUNCTION: return "FUNCTION"; | 6224 case FUNCTION: return "FUNCTION"; |
6224 case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION"; | 6225 case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION"; |
6225 case STUB: return "STUB"; | 6226 case STUB: return "STUB"; |
6226 case BUILTIN: return "BUILTIN"; | 6227 case BUILTIN: return "BUILTIN"; |
6227 case LOAD_IC: return "LOAD_IC"; | 6228 case LOAD_IC: return "LOAD_IC"; |
6228 case KEYED_LOAD_IC: return "KEYED_LOAD_IC"; | 6229 case KEYED_LOAD_IC: return "KEYED_LOAD_IC"; |
6230 case KEYED_EXTERNAL_ARRAY_LOAD_IC: return "KEYED_EXTERNAL_ARRAY_LOAD_IC"; | |
6229 case STORE_IC: return "STORE_IC"; | 6231 case STORE_IC: return "STORE_IC"; |
6230 case KEYED_STORE_IC: return "KEYED_STORE_IC"; | 6232 case KEYED_STORE_IC: return "KEYED_STORE_IC"; |
6233 case KEYED_EXTERNAL_ARRAY_STORE_IC: return "KEYED_EXTERNAL_ARRAY_STORE_IC"; | |
6231 case CALL_IC: return "CALL_IC"; | 6234 case CALL_IC: return "CALL_IC"; |
6232 case KEYED_CALL_IC: return "KEYED_CALL_IC"; | 6235 case KEYED_CALL_IC: return "KEYED_CALL_IC"; |
6233 case BINARY_OP_IC: return "BINARY_OP_IC"; | 6236 case BINARY_OP_IC: return "BINARY_OP_IC"; |
6234 case TYPE_RECORDING_BINARY_OP_IC: return "TYPE_RECORDING_BINARY_OP_IC"; | 6237 case TYPE_RECORDING_BINARY_OP_IC: return "TYPE_RECORDING_BINARY_OP_IC"; |
6235 case COMPARE_IC: return "COMPARE_IC"; | 6238 case COMPARE_IC: return "COMPARE_IC"; |
6236 } | 6239 } |
6237 UNREACHABLE(); | 6240 UNREACHABLE(); |
6238 return NULL; | 6241 return NULL; |
6239 } | 6242 } |
6240 | 6243 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6369 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 6372 PrintF("RelocInfo (size = %d)\n", relocation_size()); |
6370 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); | 6373 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); |
6371 PrintF(out, "\n"); | 6374 PrintF(out, "\n"); |
6372 } | 6375 } |
6373 #endif // ENABLE_DISASSEMBLER | 6376 #endif // ENABLE_DISASSEMBLER |
6374 | 6377 |
6375 | 6378 |
6376 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, | 6379 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, |
6377 int length) { | 6380 int length) { |
6378 // We should never end in here with a pixel or external array. | 6381 // We should never end in here with a pixel or external array. |
6379 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 6382 ASSERT(!HasExternalArrayElements()); |
6380 | 6383 |
6381 Object* obj; | 6384 Object* obj; |
6382 { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity); | 6385 { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity); |
6383 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6386 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6384 } | 6387 } |
6385 FixedArray* elems = FixedArray::cast(obj); | 6388 FixedArray* elems = FixedArray::cast(obj); |
6386 | 6389 |
6387 { MaybeObject* maybe_obj = map()->GetFastElementsMap(); | 6390 { MaybeObject* maybe_obj = map()->GetFastElementsMap(); |
6388 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6391 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6389 } | 6392 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6423 if (IsJSArray()) { | 6426 if (IsJSArray()) { |
6424 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 6427 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
6425 } | 6428 } |
6426 | 6429 |
6427 return this; | 6430 return this; |
6428 } | 6431 } |
6429 | 6432 |
6430 | 6433 |
6431 MaybeObject* JSObject::SetSlowElements(Object* len) { | 6434 MaybeObject* JSObject::SetSlowElements(Object* len) { |
6432 // We should never end in here with a pixel or external array. | 6435 // We should never end in here with a pixel or external array. |
6433 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 6436 ASSERT(!HasExternalArrayElements()); |
6434 | 6437 |
6435 uint32_t new_length = static_cast<uint32_t>(len->Number()); | 6438 uint32_t new_length = static_cast<uint32_t>(len->Number()); |
6436 | 6439 |
6437 switch (GetElementsKind()) { | 6440 switch (GetElementsKind()) { |
6438 case FAST_ELEMENTS: { | 6441 case FAST_ELEMENTS: { |
6439 // Make sure we never try to shrink dense arrays into sparse arrays. | 6442 // Make sure we never try to shrink dense arrays into sparse arrays. |
6440 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= | 6443 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= |
6441 new_length); | 6444 new_length); |
6442 Object* obj; | 6445 Object* obj; |
6443 { MaybeObject* maybe_obj = NormalizeElements(); | 6446 { MaybeObject* maybe_obj = NormalizeElements(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6652 uint32_t length = IsJSArray() ? | 6655 uint32_t length = IsJSArray() ? |
6653 static_cast<uint32_t> | 6656 static_cast<uint32_t> |
6654 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6657 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6655 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6658 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6656 if ((index < length) && | 6659 if ((index < length) && |
6657 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | 6660 !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
6658 return true; | 6661 return true; |
6659 } | 6662 } |
6660 break; | 6663 break; |
6661 } | 6664 } |
6662 case PIXEL_ELEMENTS: { | 6665 case EXTERNAL_PIXEL_ELEMENTS: { |
6663 // TODO(iposva): Add testcase. | 6666 // TODO(iposva): Add testcase. |
6664 PixelArray* pixels = PixelArray::cast(elements()); | 6667 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6665 if (index < static_cast<uint32_t>(pixels->length())) { | 6668 if (index < static_cast<uint32_t>(pixels->length())) { |
6666 return true; | 6669 return true; |
6667 } | 6670 } |
6668 break; | 6671 break; |
6669 } | 6672 } |
6670 case EXTERNAL_BYTE_ELEMENTS: | 6673 case EXTERNAL_BYTE_ELEMENTS: |
6671 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6674 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6672 case EXTERNAL_SHORT_ELEMENTS: | 6675 case EXTERNAL_SHORT_ELEMENTS: |
6673 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6676 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6674 case EXTERNAL_INT_ELEMENTS: | 6677 case EXTERNAL_INT_ELEMENTS: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6773 uint32_t length = IsJSArray() ? | 6776 uint32_t length = IsJSArray() ? |
6774 static_cast<uint32_t> | 6777 static_cast<uint32_t> |
6775 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6778 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6776 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6779 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6777 if ((index < length) && | 6780 if ((index < length) && |
6778 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | 6781 !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
6779 return FAST_ELEMENT; | 6782 return FAST_ELEMENT; |
6780 } | 6783 } |
6781 break; | 6784 break; |
6782 } | 6785 } |
6783 case PIXEL_ELEMENTS: { | 6786 case EXTERNAL_PIXEL_ELEMENTS: { |
6784 PixelArray* pixels = PixelArray::cast(elements()); | 6787 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6785 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; | 6788 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; |
6786 break; | 6789 break; |
6787 } | 6790 } |
6788 case EXTERNAL_BYTE_ELEMENTS: | 6791 case EXTERNAL_BYTE_ELEMENTS: |
6789 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6792 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6790 case EXTERNAL_SHORT_ELEMENTS: | 6793 case EXTERNAL_SHORT_ELEMENTS: |
6791 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6794 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6792 case EXTERNAL_INT_ELEMENTS: | 6795 case EXTERNAL_INT_ELEMENTS: |
6793 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 6796 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
6794 case EXTERNAL_FLOAT_ELEMENTS: { | 6797 case EXTERNAL_FLOAT_ELEMENTS: { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6828 switch (GetElementsKind()) { | 6831 switch (GetElementsKind()) { |
6829 case FAST_ELEMENTS: { | 6832 case FAST_ELEMENTS: { |
6830 uint32_t length = IsJSArray() ? | 6833 uint32_t length = IsJSArray() ? |
6831 static_cast<uint32_t> | 6834 static_cast<uint32_t> |
6832 (Smi::cast(JSArray::cast(this)->length())->value()) : | 6835 (Smi::cast(JSArray::cast(this)->length())->value()) : |
6833 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6836 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6834 if ((index < length) && | 6837 if ((index < length) && |
6835 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; | 6838 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; |
6836 break; | 6839 break; |
6837 } | 6840 } |
6838 case PIXEL_ELEMENTS: { | 6841 case EXTERNAL_PIXEL_ELEMENTS: { |
6839 PixelArray* pixels = PixelArray::cast(elements()); | 6842 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
6840 if (index < static_cast<uint32_t>(pixels->length())) { | 6843 if (index < static_cast<uint32_t>(pixels->length())) { |
6841 return true; | 6844 return true; |
6842 } | 6845 } |
6843 break; | 6846 break; |
6844 } | 6847 } |
6845 case EXTERNAL_BYTE_ELEMENTS: | 6848 case EXTERNAL_BYTE_ELEMENTS: |
6846 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 6849 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
6847 case EXTERNAL_SHORT_ELEMENTS: | 6850 case EXTERNAL_SHORT_ELEMENTS: |
6848 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 6851 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
6849 case EXTERNAL_INT_ELEMENTS: | 6852 case EXTERNAL_INT_ELEMENTS: |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7105 } | 7108 } |
7106 | 7109 |
7107 | 7110 |
7108 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, | 7111 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, |
7109 Object* value, | 7112 Object* value, |
7110 bool check_prototype) { | 7113 bool check_prototype) { |
7111 switch (GetElementsKind()) { | 7114 switch (GetElementsKind()) { |
7112 case FAST_ELEMENTS: | 7115 case FAST_ELEMENTS: |
7113 // Fast case. | 7116 // Fast case. |
7114 return SetFastElement(index, value, check_prototype); | 7117 return SetFastElement(index, value, check_prototype); |
7115 case PIXEL_ELEMENTS: { | 7118 case EXTERNAL_PIXEL_ELEMENTS: { |
7116 PixelArray* pixels = PixelArray::cast(elements()); | 7119 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7117 return pixels->SetValue(index, value); | 7120 return pixels->SetValue(index, value); |
7118 } | 7121 } |
7119 case EXTERNAL_BYTE_ELEMENTS: { | 7122 case EXTERNAL_BYTE_ELEMENTS: { |
7120 ExternalByteArray* array = ExternalByteArray::cast(elements()); | 7123 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
7121 return array->SetValue(index, value); | 7124 return array->SetValue(index, value); |
7122 } | 7125 } |
7123 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 7126 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
7124 ExternalUnsignedByteArray* array = | 7127 ExternalUnsignedByteArray* array = |
7125 ExternalUnsignedByteArray::cast(elements()); | 7128 ExternalUnsignedByteArray::cast(elements()); |
7126 return array->SetValue(index, value); | 7129 return array->SetValue(index, value); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7258 // JSArray::length cannot change. | 7261 // JSArray::length cannot change. |
7259 switch (GetElementsKind()) { | 7262 switch (GetElementsKind()) { |
7260 case FAST_ELEMENTS: { | 7263 case FAST_ELEMENTS: { |
7261 FixedArray* elms = FixedArray::cast(elements()); | 7264 FixedArray* elms = FixedArray::cast(elements()); |
7262 if (index < static_cast<uint32_t>(elms->length())) { | 7265 if (index < static_cast<uint32_t>(elms->length())) { |
7263 Object* value = elms->get(index); | 7266 Object* value = elms->get(index); |
7264 if (!value->IsTheHole()) return value; | 7267 if (!value->IsTheHole()) return value; |
7265 } | 7268 } |
7266 break; | 7269 break; |
7267 } | 7270 } |
7268 case PIXEL_ELEMENTS: { | 7271 case EXTERNAL_PIXEL_ELEMENTS: { |
7269 // TODO(iposva): Add testcase and implement. | 7272 // TODO(iposva): Add testcase and implement. |
Mads Ager (chromium)
2011/02/21 13:32:27
Scary. We should do this.
| |
7270 UNIMPLEMENTED(); | 7273 UNIMPLEMENTED(); |
7271 break; | 7274 break; |
7272 } | 7275 } |
7273 case EXTERNAL_BYTE_ELEMENTS: | 7276 case EXTERNAL_BYTE_ELEMENTS: |
7274 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7277 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7275 case EXTERNAL_SHORT_ELEMENTS: | 7278 case EXTERNAL_SHORT_ELEMENTS: |
7276 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7279 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7277 case EXTERNAL_INT_ELEMENTS: | 7280 case EXTERNAL_INT_ELEMENTS: |
7278 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7281 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7279 case EXTERNAL_FLOAT_ELEMENTS: { | 7282 case EXTERNAL_FLOAT_ELEMENTS: { |
7280 // TODO(kbr): Add testcase and implement. | 7283 // TODO(kbr): Add testcase and implement. |
Mads Ager (chromium)
2011/02/21 13:32:27
Scary. We should do this.
| |
7281 UNIMPLEMENTED(); | 7284 UNIMPLEMENTED(); |
7282 break; | 7285 break; |
7283 } | 7286 } |
7284 case DICTIONARY_ELEMENTS: { | 7287 case DICTIONARY_ELEMENTS: { |
7285 NumberDictionary* dictionary = element_dictionary(); | 7288 NumberDictionary* dictionary = element_dictionary(); |
7286 int entry = dictionary->FindEntry(index); | 7289 int entry = dictionary->FindEntry(index); |
7287 if (entry != NumberDictionary::kNotFound) { | 7290 if (entry != NumberDictionary::kNotFound) { |
7288 Object* element = dictionary->ValueAt(entry); | 7291 Object* element = dictionary->ValueAt(entry); |
7289 PropertyDetails details = dictionary->DetailsAt(entry); | 7292 PropertyDetails details = dictionary->DetailsAt(entry); |
7290 if (details.type() == CALLBACKS) { | 7293 if (details.type() == CALLBACKS) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7359 // JSArray::length cannot change. | 7362 // JSArray::length cannot change. |
7360 switch (GetElementsKind()) { | 7363 switch (GetElementsKind()) { |
7361 case FAST_ELEMENTS: { | 7364 case FAST_ELEMENTS: { |
7362 FixedArray* elms = FixedArray::cast(elements()); | 7365 FixedArray* elms = FixedArray::cast(elements()); |
7363 if (index < static_cast<uint32_t>(elms->length())) { | 7366 if (index < static_cast<uint32_t>(elms->length())) { |
7364 Object* value = elms->get(index); | 7367 Object* value = elms->get(index); |
7365 if (!value->IsTheHole()) return value; | 7368 if (!value->IsTheHole()) return value; |
7366 } | 7369 } |
7367 break; | 7370 break; |
7368 } | 7371 } |
7369 case PIXEL_ELEMENTS: { | 7372 case EXTERNAL_PIXEL_ELEMENTS: { |
7370 PixelArray* pixels = PixelArray::cast(elements()); | 7373 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7371 if (index < static_cast<uint32_t>(pixels->length())) { | 7374 if (index < static_cast<uint32_t>(pixels->length())) { |
7372 uint8_t value = pixels->get(index); | 7375 uint8_t value = pixels->get(index); |
7373 return Smi::FromInt(value); | 7376 return Smi::FromInt(value); |
7374 } | 7377 } |
7375 break; | 7378 break; |
7376 } | 7379 } |
7377 case EXTERNAL_BYTE_ELEMENTS: { | 7380 case EXTERNAL_BYTE_ELEMENTS: { |
7378 ExternalByteArray* array = ExternalByteArray::cast(elements()); | 7381 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
7379 if (index < static_cast<uint32_t>(array->length())) { | 7382 if (index < static_cast<uint32_t>(array->length())) { |
7380 int8_t value = array->get(index); | 7383 int8_t value = array->get(index); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7463 | 7466 |
7464 switch (GetElementsKind()) { | 7467 switch (GetElementsKind()) { |
7465 case FAST_ELEMENTS: { | 7468 case FAST_ELEMENTS: { |
7466 FixedArray* elms = FixedArray::cast(elements()); | 7469 FixedArray* elms = FixedArray::cast(elements()); |
7467 capacity = elms->length(); | 7470 capacity = elms->length(); |
7468 for (int i = 0; i < capacity; i++) { | 7471 for (int i = 0; i < capacity; i++) { |
7469 if (!elms->get(i)->IsTheHole()) number_of_elements++; | 7472 if (!elms->get(i)->IsTheHole()) number_of_elements++; |
7470 } | 7473 } |
7471 break; | 7474 break; |
7472 } | 7475 } |
7473 case PIXEL_ELEMENTS: | 7476 case EXTERNAL_PIXEL_ELEMENTS: |
7474 case EXTERNAL_BYTE_ELEMENTS: | 7477 case EXTERNAL_BYTE_ELEMENTS: |
7475 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7478 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7476 case EXTERNAL_SHORT_ELEMENTS: | 7479 case EXTERNAL_SHORT_ELEMENTS: |
7477 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7480 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7478 case EXTERNAL_INT_ELEMENTS: | 7481 case EXTERNAL_INT_ELEMENTS: |
7479 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7482 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7480 case EXTERNAL_FLOAT_ELEMENTS: { | 7483 case EXTERNAL_FLOAT_ELEMENTS: { |
7481 return true; | 7484 return true; |
7482 } | 7485 } |
7483 case DICTIONARY_ELEMENTS: { | 7486 case DICTIONARY_ELEMENTS: { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7691 | 7694 |
7692 switch (GetElementsKind()) { | 7695 switch (GetElementsKind()) { |
7693 case FAST_ELEMENTS: { | 7696 case FAST_ELEMENTS: { |
7694 uint32_t length = IsJSArray() ? | 7697 uint32_t length = IsJSArray() ? |
7695 static_cast<uint32_t>( | 7698 static_cast<uint32_t>( |
7696 Smi::cast(JSArray::cast(this)->length())->value()) : | 7699 Smi::cast(JSArray::cast(this)->length())->value()) : |
7697 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 7700 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
7698 return (index < length) && | 7701 return (index < length) && |
7699 !FixedArray::cast(elements())->get(index)->IsTheHole(); | 7702 !FixedArray::cast(elements())->get(index)->IsTheHole(); |
7700 } | 7703 } |
7701 case PIXEL_ELEMENTS: { | 7704 case EXTERNAL_PIXEL_ELEMENTS: { |
7702 PixelArray* pixels = PixelArray::cast(elements()); | 7705 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
7703 return index < static_cast<uint32_t>(pixels->length()); | 7706 return index < static_cast<uint32_t>(pixels->length()); |
7704 } | 7707 } |
7705 case EXTERNAL_BYTE_ELEMENTS: | 7708 case EXTERNAL_BYTE_ELEMENTS: |
7706 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 7709 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
7707 case EXTERNAL_SHORT_ELEMENTS: | 7710 case EXTERNAL_SHORT_ELEMENTS: |
7708 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 7711 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
7709 case EXTERNAL_INT_ELEMENTS: | 7712 case EXTERNAL_INT_ELEMENTS: |
7710 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 7713 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
7711 case EXTERNAL_FLOAT_ELEMENTS: { | 7714 case EXTERNAL_FLOAT_ELEMENTS: { |
7712 ExternalArray* array = ExternalArray::cast(elements()); | 7715 ExternalArray* array = ExternalArray::cast(elements()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7923 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { | 7926 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { |
7924 if (storage != NULL) { | 7927 if (storage != NULL) { |
7925 storage->set(counter, Smi::FromInt(i)); | 7928 storage->set(counter, Smi::FromInt(i)); |
7926 } | 7929 } |
7927 counter++; | 7930 counter++; |
7928 } | 7931 } |
7929 } | 7932 } |
7930 ASSERT(!storage || storage->length() >= counter); | 7933 ASSERT(!storage || storage->length() >= counter); |
7931 break; | 7934 break; |
7932 } | 7935 } |
7933 case PIXEL_ELEMENTS: { | 7936 case EXTERNAL_PIXEL_ELEMENTS: { |
7934 int length = PixelArray::cast(elements())->length(); | 7937 int length = ExternalPixelArray::cast(elements())->length(); |
7935 while (counter < length) { | 7938 while (counter < length) { |
7936 if (storage != NULL) { | 7939 if (storage != NULL) { |
7937 storage->set(counter, Smi::FromInt(counter)); | 7940 storage->set(counter, Smi::FromInt(counter)); |
7938 } | 7941 } |
7939 counter++; | 7942 counter++; |
7940 } | 7943 } |
7941 ASSERT(!storage || storage->length() >= counter); | 7944 ASSERT(!storage || storage->length() >= counter); |
7942 break; | 7945 break; |
7943 } | 7946 } |
7944 case EXTERNAL_BYTE_ELEMENTS: | 7947 case EXTERNAL_BYTE_ELEMENTS: |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8665 result_double->set_value(static_cast<double>(result)); | 8668 result_double->set_value(static_cast<double>(result)); |
8666 return result_double; | 8669 return result_double; |
8667 } | 8670 } |
8668 | 8671 |
8669 | 8672 |
8670 // Collects all defined (non-hole) and non-undefined (array) elements at | 8673 // Collects all defined (non-hole) and non-undefined (array) elements at |
8671 // the start of the elements array. | 8674 // the start of the elements array. |
8672 // If the object is in dictionary mode, it is converted to fast elements | 8675 // If the object is in dictionary mode, it is converted to fast elements |
8673 // mode. | 8676 // mode. |
8674 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { | 8677 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { |
8675 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 8678 ASSERT(!HasExternalArrayElements()); |
8676 | 8679 |
8677 if (HasDictionaryElements()) { | 8680 if (HasDictionaryElements()) { |
8678 // Convert to fast elements containing only the existing properties. | 8681 // Convert to fast elements containing only the existing properties. |
8679 // Ordering is irrelevant, since we are going to sort anyway. | 8682 // Ordering is irrelevant, since we are going to sort anyway. |
8680 NumberDictionary* dict = element_dictionary(); | 8683 NumberDictionary* dict = element_dictionary(); |
8681 if (IsJSArray() || dict->requires_slow_elements() || | 8684 if (IsJSArray() || dict->requires_slow_elements() || |
8682 dict->max_number_key() >= limit) { | 8685 dict->max_number_key() >= limit) { |
8683 return PrepareSlowElementsForSort(limit); | 8686 return PrepareSlowElementsForSort(limit); |
8684 } | 8687 } |
8685 // Convert to fast elements. | 8688 // Convert to fast elements. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8777 | 8780 |
8778 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { | 8781 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { |
8779 return Smi::FromInt(static_cast<int>(result)); | 8782 return Smi::FromInt(static_cast<int>(result)); |
8780 } | 8783 } |
8781 ASSERT_NE(NULL, result_double); | 8784 ASSERT_NE(NULL, result_double); |
8782 result_double->set_value(static_cast<double>(result)); | 8785 result_double->set_value(static_cast<double>(result)); |
8783 return result_double; | 8786 return result_double; |
8784 } | 8787 } |
8785 | 8788 |
8786 | 8789 |
8787 Object* PixelArray::SetValue(uint32_t index, Object* value) { | 8790 Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { |
8788 uint8_t clamped_value = 0; | 8791 uint8_t clamped_value = 0; |
8789 if (index < static_cast<uint32_t>(length())) { | 8792 if (index < static_cast<uint32_t>(length())) { |
8790 if (value->IsSmi()) { | 8793 if (value->IsSmi()) { |
8791 int int_value = Smi::cast(value)->value(); | 8794 int int_value = Smi::cast(value)->value(); |
8792 if (int_value < 0) { | 8795 if (int_value < 0) { |
8793 clamped_value = 0; | 8796 clamped_value = 0; |
8794 } else if (int_value > 255) { | 8797 } else if (int_value > 255) { |
8795 clamped_value = 255; | 8798 clamped_value = 255; |
8796 } else { | 8799 } else { |
8797 clamped_value = static_cast<uint8_t>(int_value); | 8800 clamped_value = static_cast<uint8_t>(int_value); |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9985 if (break_point_objects()->IsUndefined()) return 0; | 9988 if (break_point_objects()->IsUndefined()) return 0; |
9986 // Single beak point. | 9989 // Single beak point. |
9987 if (!break_point_objects()->IsFixedArray()) return 1; | 9990 if (!break_point_objects()->IsFixedArray()) return 1; |
9988 // Multiple break points. | 9991 // Multiple break points. |
9989 return FixedArray::cast(break_point_objects())->length(); | 9992 return FixedArray::cast(break_point_objects())->length(); |
9990 } | 9993 } |
9991 #endif | 9994 #endif |
9992 | 9995 |
9993 | 9996 |
9994 } } // namespace v8::internal | 9997 } } // namespace v8::internal |
OLD | NEW |