OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 break; | 998 break; |
999 case FIXED_ARRAY_TYPE: | 999 case FIXED_ARRAY_TYPE: |
1000 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); | 1000 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); |
1001 break; | 1001 break; |
1002 case BYTE_ARRAY_TYPE: | 1002 case BYTE_ARRAY_TYPE: |
1003 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); | 1003 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); |
1004 break; | 1004 break; |
1005 case PIXEL_ARRAY_TYPE: | 1005 case PIXEL_ARRAY_TYPE: |
1006 accumulator->Add("<PixelArray[%u]>", PixelArray::cast(this)->length()); | 1006 accumulator->Add("<PixelArray[%u]>", PixelArray::cast(this)->length()); |
1007 break; | 1007 break; |
| 1008 case EXTERNAL_BYTE_ARRAY_TYPE: |
| 1009 accumulator->Add("<ExternalByteArray[%u]>", |
| 1010 ExternalByteArray::cast(this)->length()); |
| 1011 break; |
| 1012 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 1013 accumulator->Add("<ExternalUnsignedByteArray[%u]>", |
| 1014 ExternalUnsignedByteArray::cast(this)->length()); |
| 1015 break; |
| 1016 case EXTERNAL_SHORT_ARRAY_TYPE: |
| 1017 accumulator->Add("<ExternalShortArray[%u]>", |
| 1018 ExternalShortArray::cast(this)->length()); |
| 1019 break; |
| 1020 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 1021 accumulator->Add("<ExternalUnsignedShortArray[%u]>", |
| 1022 ExternalUnsignedShortArray::cast(this)->length()); |
| 1023 break; |
| 1024 case EXTERNAL_INT_ARRAY_TYPE: |
| 1025 accumulator->Add("<ExternalIntArray[%u]>", |
| 1026 ExternalIntArray::cast(this)->length()); |
| 1027 break; |
| 1028 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 1029 accumulator->Add("<ExternalUnsignedIntArray[%u]>", |
| 1030 ExternalUnsignedIntArray::cast(this)->length()); |
| 1031 break; |
| 1032 case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 1033 accumulator->Add("<ExternalFloatArray[%u]>", |
| 1034 ExternalFloatArray::cast(this)->length()); |
| 1035 break; |
1008 case SHARED_FUNCTION_INFO_TYPE: | 1036 case SHARED_FUNCTION_INFO_TYPE: |
1009 accumulator->Add("<SharedFunctionInfo>"); | 1037 accumulator->Add("<SharedFunctionInfo>"); |
1010 break; | 1038 break; |
1011 #define MAKE_STRUCT_CASE(NAME, Name, name) \ | 1039 #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
1012 case NAME##_TYPE: \ | 1040 case NAME##_TYPE: \ |
1013 accumulator->Put('<'); \ | 1041 accumulator->Put('<'); \ |
1014 accumulator->Add(#Name); \ | 1042 accumulator->Add(#Name); \ |
1015 accumulator->Put('>'); \ | 1043 accumulator->Put('>'); \ |
1016 break; | 1044 break; |
1017 STRUCT_LIST(MAKE_STRUCT_CASE) | 1045 STRUCT_LIST(MAKE_STRUCT_CASE) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 reinterpret_cast<Code*>(this)->CodeIterateBody(v); | 1168 reinterpret_cast<Code*>(this)->CodeIterateBody(v); |
1141 break; | 1169 break; |
1142 case JS_GLOBAL_PROPERTY_CELL_TYPE: | 1170 case JS_GLOBAL_PROPERTY_CELL_TYPE: |
1143 reinterpret_cast<JSGlobalPropertyCell*>(this) | 1171 reinterpret_cast<JSGlobalPropertyCell*>(this) |
1144 ->JSGlobalPropertyCellIterateBody(v); | 1172 ->JSGlobalPropertyCellIterateBody(v); |
1145 break; | 1173 break; |
1146 case HEAP_NUMBER_TYPE: | 1174 case HEAP_NUMBER_TYPE: |
1147 case FILLER_TYPE: | 1175 case FILLER_TYPE: |
1148 case BYTE_ARRAY_TYPE: | 1176 case BYTE_ARRAY_TYPE: |
1149 case PIXEL_ARRAY_TYPE: | 1177 case PIXEL_ARRAY_TYPE: |
| 1178 case EXTERNAL_BYTE_ARRAY_TYPE: |
| 1179 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 1180 case EXTERNAL_SHORT_ARRAY_TYPE: |
| 1181 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 1182 case EXTERNAL_INT_ARRAY_TYPE: |
| 1183 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 1184 case EXTERNAL_FLOAT_ARRAY_TYPE: |
1150 break; | 1185 break; |
1151 case SHARED_FUNCTION_INFO_TYPE: { | 1186 case SHARED_FUNCTION_INFO_TYPE: { |
1152 SharedFunctionInfo* shared = reinterpret_cast<SharedFunctionInfo*>(this); | 1187 SharedFunctionInfo* shared = reinterpret_cast<SharedFunctionInfo*>(this); |
1153 shared->SharedFunctionInfoIterateBody(v); | 1188 shared->SharedFunctionInfoIterateBody(v); |
1154 break; | 1189 break; |
1155 } | 1190 } |
1156 #define MAKE_STRUCT_CASE(NAME, Name, name) \ | 1191 #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
1157 case NAME##_TYPE: | 1192 case NAME##_TYPE: |
1158 STRUCT_LIST(MAKE_STRUCT_CASE) | 1193 STRUCT_LIST(MAKE_STRUCT_CASE) |
1159 #undef MAKE_STRUCT_CASE | 1194 #undef MAKE_STRUCT_CASE |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 | 2265 |
2231 Object* JSObject::TransformToFastProperties(int unused_property_fields) { | 2266 Object* JSObject::TransformToFastProperties(int unused_property_fields) { |
2232 if (HasFastProperties()) return this; | 2267 if (HasFastProperties()) return this; |
2233 ASSERT(!IsGlobalObject()); | 2268 ASSERT(!IsGlobalObject()); |
2234 return property_dictionary()-> | 2269 return property_dictionary()-> |
2235 TransformPropertiesToFastFor(this, unused_property_fields); | 2270 TransformPropertiesToFastFor(this, unused_property_fields); |
2236 } | 2271 } |
2237 | 2272 |
2238 | 2273 |
2239 Object* JSObject::NormalizeElements() { | 2274 Object* JSObject::NormalizeElements() { |
2240 ASSERT(!HasPixelElements()); | 2275 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
2241 if (HasDictionaryElements()) return this; | 2276 if (HasDictionaryElements()) return this; |
2242 | 2277 |
2243 // Get number of entries. | 2278 // Get number of entries. |
2244 FixedArray* array = FixedArray::cast(elements()); | 2279 FixedArray* array = FixedArray::cast(elements()); |
2245 | 2280 |
2246 // Compute the effective length. | 2281 // Compute the effective length. |
2247 int length = IsJSArray() ? | 2282 int length = IsJSArray() ? |
2248 Smi::cast(JSArray::cast(this)->length())->value() : | 2283 Smi::cast(JSArray::cast(this)->length())->value() : |
2249 array->length(); | 2284 array->length(); |
2250 Object* obj = NumberDictionary::Allocate(length); | 2285 Object* obj = NumberDictionary::Allocate(length); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 } | 2350 } |
2316 Object* raw_result = | 2351 Object* raw_result = |
2317 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); | 2352 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); |
2318 RETURN_IF_SCHEDULED_EXCEPTION(); | 2353 RETURN_IF_SCHEDULED_EXCEPTION(); |
2319 return raw_result; | 2354 return raw_result; |
2320 } | 2355 } |
2321 | 2356 |
2322 | 2357 |
2323 Object* JSObject::DeleteElementPostInterceptor(uint32_t index, | 2358 Object* JSObject::DeleteElementPostInterceptor(uint32_t index, |
2324 DeleteMode mode) { | 2359 DeleteMode mode) { |
2325 ASSERT(!HasPixelElements()); | 2360 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
2326 switch (GetElementsKind()) { | 2361 switch (GetElementsKind()) { |
2327 case FAST_ELEMENTS: { | 2362 case FAST_ELEMENTS: { |
2328 uint32_t length = IsJSArray() ? | 2363 uint32_t length = IsJSArray() ? |
2329 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2364 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2330 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2365 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2331 if (index < length) { | 2366 if (index < length) { |
2332 FixedArray::cast(elements())->set_the_hole(index); | 2367 FixedArray::cast(elements())->set_the_hole(index); |
2333 } | 2368 } |
2334 break; | 2369 break; |
2335 } | 2370 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 switch (GetElementsKind()) { | 2441 switch (GetElementsKind()) { |
2407 case FAST_ELEMENTS: { | 2442 case FAST_ELEMENTS: { |
2408 uint32_t length = IsJSArray() ? | 2443 uint32_t length = IsJSArray() ? |
2409 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : | 2444 static_cast<uint32_t>(Smi::cast(JSArray::cast(this)->length())->value()) : |
2410 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 2445 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
2411 if (index < length) { | 2446 if (index < length) { |
2412 FixedArray::cast(elements())->set_the_hole(index); | 2447 FixedArray::cast(elements())->set_the_hole(index); |
2413 } | 2448 } |
2414 break; | 2449 break; |
2415 } | 2450 } |
2416 case PIXEL_ELEMENTS: { | 2451 case PIXEL_ELEMENTS: |
2417 // Pixel elements cannot be deleted. Just silently ignore here. | 2452 case EXTERNAL_BYTE_ELEMENTS: |
| 2453 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2454 case EXTERNAL_SHORT_ELEMENTS: |
| 2455 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 2456 case EXTERNAL_INT_ELEMENTS: |
| 2457 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 2458 case EXTERNAL_FLOAT_ELEMENTS: |
| 2459 // Pixel and external array elements cannot be deleted. Just |
| 2460 // silently ignore here. |
2418 break; | 2461 break; |
2419 } | |
2420 case DICTIONARY_ELEMENTS: { | 2462 case DICTIONARY_ELEMENTS: { |
2421 NumberDictionary* dictionary = element_dictionary(); | 2463 NumberDictionary* dictionary = element_dictionary(); |
2422 int entry = dictionary->FindEntry(index); | 2464 int entry = dictionary->FindEntry(index); |
2423 if (entry != NumberDictionary::kNotFound) { | 2465 if (entry != NumberDictionary::kNotFound) { |
2424 return dictionary->DeleteProperty(entry, mode); | 2466 return dictionary->DeleteProperty(entry, mode); |
2425 } | 2467 } |
2426 break; | 2468 break; |
2427 } | 2469 } |
2428 default: | 2470 default: |
2429 UNREACHABLE(); | 2471 UNREACHABLE(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 | 2542 |
2501 // Check if the object is among the named properties. | 2543 // Check if the object is among the named properties. |
2502 Object* key = SlowReverseLookup(obj); | 2544 Object* key = SlowReverseLookup(obj); |
2503 if (key != Heap::undefined_value()) { | 2545 if (key != Heap::undefined_value()) { |
2504 return true; | 2546 return true; |
2505 } | 2547 } |
2506 | 2548 |
2507 // Check if the object is among the indexed properties. | 2549 // Check if the object is among the indexed properties. |
2508 switch (GetElementsKind()) { | 2550 switch (GetElementsKind()) { |
2509 case PIXEL_ELEMENTS: | 2551 case PIXEL_ELEMENTS: |
2510 // Raw pixels do not reference other objects. | 2552 case EXTERNAL_BYTE_ELEMENTS: |
| 2553 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2554 case EXTERNAL_SHORT_ELEMENTS: |
| 2555 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 2556 case EXTERNAL_INT_ELEMENTS: |
| 2557 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 2558 case EXTERNAL_FLOAT_ELEMENTS: |
| 2559 // Raw pixels and external arrays do not reference other |
| 2560 // objects. |
2511 break; | 2561 break; |
2512 case FAST_ELEMENTS: { | 2562 case FAST_ELEMENTS: { |
2513 int length = IsJSArray() ? | 2563 int length = IsJSArray() ? |
2514 Smi::cast(JSArray::cast(this)->length())->value() : | 2564 Smi::cast(JSArray::cast(this)->length())->value() : |
2515 FixedArray::cast(elements())->length(); | 2565 FixedArray::cast(elements())->length(); |
2516 for (int i = 0; i < length; i++) { | 2566 for (int i = 0; i < length; i++) { |
2517 Object* element = FixedArray::cast(elements())->get(i); | 2567 Object* element = FixedArray::cast(elements())->get(i); |
2518 if (!element->IsTheHole() && element == obj) { | 2568 if (!element->IsTheHole() && element == obj) { |
2519 return true; | 2569 return true; |
2520 } | 2570 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 | 2795 |
2746 uint32_t index; | 2796 uint32_t index; |
2747 bool is_element = name->AsArrayIndex(&index); | 2797 bool is_element = name->AsArrayIndex(&index); |
2748 if (is_element && IsJSArray()) return Heap::undefined_value(); | 2798 if (is_element && IsJSArray()) return Heap::undefined_value(); |
2749 | 2799 |
2750 if (is_element) { | 2800 if (is_element) { |
2751 switch (GetElementsKind()) { | 2801 switch (GetElementsKind()) { |
2752 case FAST_ELEMENTS: | 2802 case FAST_ELEMENTS: |
2753 break; | 2803 break; |
2754 case PIXEL_ELEMENTS: | 2804 case PIXEL_ELEMENTS: |
2755 // Ignore getters and setters on pixel elements. | 2805 case EXTERNAL_BYTE_ELEMENTS: |
| 2806 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2807 case EXTERNAL_SHORT_ELEMENTS: |
| 2808 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 2809 case EXTERNAL_INT_ELEMENTS: |
| 2810 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 2811 case EXTERNAL_FLOAT_ELEMENTS: |
| 2812 // Ignore getters and setters on pixel and external array |
| 2813 // elements. |
2756 return Heap::undefined_value(); | 2814 return Heap::undefined_value(); |
2757 case DICTIONARY_ELEMENTS: { | 2815 case DICTIONARY_ELEMENTS: { |
2758 // Lookup the index. | 2816 // Lookup the index. |
2759 NumberDictionary* dictionary = element_dictionary(); | 2817 NumberDictionary* dictionary = element_dictionary(); |
2760 int entry = dictionary->FindEntry(index); | 2818 int entry = dictionary->FindEntry(index); |
2761 if (entry != NumberDictionary::kNotFound) { | 2819 if (entry != NumberDictionary::kNotFound) { |
2762 Object* result = dictionary->ValueAt(entry); | 2820 Object* result = dictionary->ValueAt(entry); |
2763 PropertyDetails details = dictionary->DetailsAt(entry); | 2821 PropertyDetails details = dictionary->DetailsAt(entry); |
2764 if (details.IsReadOnly()) return Heap::undefined_value(); | 2822 if (details.IsReadOnly()) return Heap::undefined_value(); |
2765 if (details.type() == CALLBACKS) { | 2823 if (details.type() == CALLBACKS) { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 if (element->IsString() && | 3138 if (element->IsString() && |
3081 key->IsString() && String::cast(element)->Equals(String::cast(key))) { | 3139 key->IsString() && String::cast(element)->Equals(String::cast(key))) { |
3082 return true; | 3140 return true; |
3083 } | 3141 } |
3084 } | 3142 } |
3085 return false; | 3143 return false; |
3086 } | 3144 } |
3087 | 3145 |
3088 | 3146 |
3089 Object* FixedArray::AddKeysFromJSArray(JSArray* array) { | 3147 Object* FixedArray::AddKeysFromJSArray(JSArray* array) { |
3090 ASSERT(!array->HasPixelElements()); | 3148 ASSERT(!array->HasPixelElements() && !array->HasExternalArrayElements()); |
3091 switch (array->GetElementsKind()) { | 3149 switch (array->GetElementsKind()) { |
3092 case JSObject::FAST_ELEMENTS: | 3150 case JSObject::FAST_ELEMENTS: |
3093 return UnionOfKeys(FixedArray::cast(array->elements())); | 3151 return UnionOfKeys(FixedArray::cast(array->elements())); |
3094 case JSObject::DICTIONARY_ELEMENTS: { | 3152 case JSObject::DICTIONARY_ELEMENTS: { |
3095 NumberDictionary* dict = array->element_dictionary(); | 3153 NumberDictionary* dict = array->element_dictionary(); |
3096 int size = dict->NumberOfElements(); | 3154 int size = dict->NumberOfElements(); |
3097 | 3155 |
3098 // Allocate a temporary fixed array. | 3156 // Allocate a temporary fixed array. |
3099 Object* object = Heap::AllocateFixedArray(size); | 3157 Object* object = Heap::AllocateFixedArray(size); |
3100 if (object->IsFailure()) return object; | 3158 if (object->IsFailure()) return object; |
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5194 | 5252 |
5195 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 5253 PrintF("RelocInfo (size = %d)\n", relocation_size()); |
5196 for (RelocIterator it(this); !it.done(); it.next()) | 5254 for (RelocIterator it(this); !it.done(); it.next()) |
5197 it.rinfo()->Print(); | 5255 it.rinfo()->Print(); |
5198 PrintF("\n"); | 5256 PrintF("\n"); |
5199 } | 5257 } |
5200 #endif // ENABLE_DISASSEMBLER | 5258 #endif // ENABLE_DISASSEMBLER |
5201 | 5259 |
5202 | 5260 |
5203 void JSObject::SetFastElements(FixedArray* elems) { | 5261 void JSObject::SetFastElements(FixedArray* elems) { |
5204 // We should never end in here with a pixel array. | 5262 // We should never end in here with a pixel or external array. |
5205 ASSERT(!HasPixelElements()); | 5263 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
5206 #ifdef DEBUG | 5264 #ifdef DEBUG |
5207 // Check the provided array is filled with the_hole. | 5265 // Check the provided array is filled with the_hole. |
5208 uint32_t len = static_cast<uint32_t>(elems->length()); | 5266 uint32_t len = static_cast<uint32_t>(elems->length()); |
5209 for (uint32_t i = 0; i < len; i++) ASSERT(elems->get(i)->IsTheHole()); | 5267 for (uint32_t i = 0; i < len; i++) ASSERT(elems->get(i)->IsTheHole()); |
5210 #endif | 5268 #endif |
5211 WriteBarrierMode mode = elems->GetWriteBarrierMode(); | 5269 WriteBarrierMode mode = elems->GetWriteBarrierMode(); |
5212 switch (GetElementsKind()) { | 5270 switch (GetElementsKind()) { |
5213 case FAST_ELEMENTS: { | 5271 case FAST_ELEMENTS: { |
5214 FixedArray* old_elements = FixedArray::cast(elements()); | 5272 FixedArray* old_elements = FixedArray::cast(elements()); |
5215 uint32_t old_length = static_cast<uint32_t>(old_elements->length()); | 5273 uint32_t old_length = static_cast<uint32_t>(old_elements->length()); |
(...skipping 16 matching lines...) Expand all Loading... |
5232 } | 5290 } |
5233 default: | 5291 default: |
5234 UNREACHABLE(); | 5292 UNREACHABLE(); |
5235 break; | 5293 break; |
5236 } | 5294 } |
5237 set_elements(elems); | 5295 set_elements(elems); |
5238 } | 5296 } |
5239 | 5297 |
5240 | 5298 |
5241 Object* JSObject::SetSlowElements(Object* len) { | 5299 Object* JSObject::SetSlowElements(Object* len) { |
5242 // We should never end in here with a pixel array. | 5300 // We should never end in here with a pixel or external array. |
5243 ASSERT(!HasPixelElements()); | 5301 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
5244 | 5302 |
5245 uint32_t new_length = static_cast<uint32_t>(len->Number()); | 5303 uint32_t new_length = static_cast<uint32_t>(len->Number()); |
5246 | 5304 |
5247 switch (GetElementsKind()) { | 5305 switch (GetElementsKind()) { |
5248 case FAST_ELEMENTS: { | 5306 case FAST_ELEMENTS: { |
5249 // Make sure we never try to shrink dense arrays into sparse arrays. | 5307 // Make sure we never try to shrink dense arrays into sparse arrays. |
5250 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= | 5308 ASSERT(static_cast<uint32_t>(FixedArray::cast(elements())->length()) <= |
5251 new_length); | 5309 new_length); |
5252 Object* obj = NormalizeElements(); | 5310 Object* obj = NormalizeElements(); |
5253 if (obj->IsFailure()) return obj; | 5311 if (obj->IsFailure()) return obj; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5311 | 5369 |
5312 | 5370 |
5313 static Object* ArrayLengthRangeError() { | 5371 static Object* ArrayLengthRangeError() { |
5314 HandleScope scope; | 5372 HandleScope scope; |
5315 return Top::Throw(*Factory::NewRangeError("invalid_array_length", | 5373 return Top::Throw(*Factory::NewRangeError("invalid_array_length", |
5316 HandleVector<Object>(NULL, 0))); | 5374 HandleVector<Object>(NULL, 0))); |
5317 } | 5375 } |
5318 | 5376 |
5319 | 5377 |
5320 Object* JSObject::SetElementsLength(Object* len) { | 5378 Object* JSObject::SetElementsLength(Object* len) { |
5321 // We should never end in here with a pixel array. | 5379 // We should never end in here with a pixel or external array. |
5322 ASSERT(!HasPixelElements()); | 5380 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
5323 | 5381 |
5324 Object* smi_length = len->ToSmi(); | 5382 Object* smi_length = len->ToSmi(); |
5325 if (smi_length->IsSmi()) { | 5383 if (smi_length->IsSmi()) { |
5326 int value = Smi::cast(smi_length)->value(); | 5384 int value = Smi::cast(smi_length)->value(); |
5327 if (value < 0) return ArrayLengthRangeError(); | 5385 if (value < 0) return ArrayLengthRangeError(); |
5328 switch (GetElementsKind()) { | 5386 switch (GetElementsKind()) { |
5329 case FAST_ELEMENTS: { | 5387 case FAST_ELEMENTS: { |
5330 int old_capacity = FixedArray::cast(elements())->length(); | 5388 int old_capacity = FixedArray::cast(elements())->length(); |
5331 if (value <= old_capacity) { | 5389 if (value <= old_capacity) { |
5332 if (IsJSArray()) { | 5390 if (IsJSArray()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5413 break; | 5471 break; |
5414 } | 5472 } |
5415 case PIXEL_ELEMENTS: { | 5473 case PIXEL_ELEMENTS: { |
5416 // TODO(iposva): Add testcase. | 5474 // TODO(iposva): Add testcase. |
5417 PixelArray* pixels = PixelArray::cast(elements()); | 5475 PixelArray* pixels = PixelArray::cast(elements()); |
5418 if (index < static_cast<uint32_t>(pixels->length())) { | 5476 if (index < static_cast<uint32_t>(pixels->length())) { |
5419 return true; | 5477 return true; |
5420 } | 5478 } |
5421 break; | 5479 break; |
5422 } | 5480 } |
| 5481 case EXTERNAL_BYTE_ELEMENTS: |
| 5482 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 5483 case EXTERNAL_SHORT_ELEMENTS: |
| 5484 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 5485 case EXTERNAL_INT_ELEMENTS: |
| 5486 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 5487 case EXTERNAL_FLOAT_ELEMENTS: { |
| 5488 // TODO(kbr): Add testcase. |
| 5489 ExternalArray* array = ExternalArray::cast(elements()); |
| 5490 if (index < static_cast<uint32_t>(array->length())) { |
| 5491 return true; |
| 5492 } |
| 5493 break; |
| 5494 } |
5423 case DICTIONARY_ELEMENTS: { | 5495 case DICTIONARY_ELEMENTS: { |
5424 if (element_dictionary()->FindEntry(index) | 5496 if (element_dictionary()->FindEntry(index) |
5425 != NumberDictionary::kNotFound) { | 5497 != NumberDictionary::kNotFound) { |
5426 return true; | 5498 return true; |
5427 } | 5499 } |
5428 break; | 5500 break; |
5429 } | 5501 } |
5430 default: | 5502 default: |
5431 UNREACHABLE(); | 5503 UNREACHABLE(); |
5432 break; | 5504 break; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5500 static_cast<uint32_t> | 5572 static_cast<uint32_t> |
5501 (Smi::cast(JSArray::cast(this)->length())->value()) : | 5573 (Smi::cast(JSArray::cast(this)->length())->value()) : |
5502 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 5574 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
5503 return (index < length) && | 5575 return (index < length) && |
5504 !FixedArray::cast(elements())->get(index)->IsTheHole(); | 5576 !FixedArray::cast(elements())->get(index)->IsTheHole(); |
5505 } | 5577 } |
5506 case PIXEL_ELEMENTS: { | 5578 case PIXEL_ELEMENTS: { |
5507 PixelArray* pixels = PixelArray::cast(elements()); | 5579 PixelArray* pixels = PixelArray::cast(elements()); |
5508 return (index < static_cast<uint32_t>(pixels->length())); | 5580 return (index < static_cast<uint32_t>(pixels->length())); |
5509 } | 5581 } |
| 5582 case EXTERNAL_BYTE_ELEMENTS: |
| 5583 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 5584 case EXTERNAL_SHORT_ELEMENTS: |
| 5585 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 5586 case EXTERNAL_INT_ELEMENTS: |
| 5587 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 5588 case EXTERNAL_FLOAT_ELEMENTS: { |
| 5589 ExternalArray* array = ExternalArray::cast(elements()); |
| 5590 return (index < static_cast<uint32_t>(array->length())); |
| 5591 } |
5510 case DICTIONARY_ELEMENTS: { | 5592 case DICTIONARY_ELEMENTS: { |
5511 return element_dictionary()->FindEntry(index) | 5593 return element_dictionary()->FindEntry(index) |
5512 != NumberDictionary::kNotFound; | 5594 != NumberDictionary::kNotFound; |
5513 } | 5595 } |
5514 default: | 5596 default: |
5515 UNREACHABLE(); | 5597 UNREACHABLE(); |
5516 break; | 5598 break; |
5517 } | 5599 } |
5518 UNREACHABLE(); | 5600 UNREACHABLE(); |
5519 return Heap::null_value(); | 5601 return Heap::null_value(); |
(...skipping 23 matching lines...) Expand all Loading... |
5543 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; | 5625 !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; |
5544 break; | 5626 break; |
5545 } | 5627 } |
5546 case PIXEL_ELEMENTS: { | 5628 case PIXEL_ELEMENTS: { |
5547 PixelArray* pixels = PixelArray::cast(elements()); | 5629 PixelArray* pixels = PixelArray::cast(elements()); |
5548 if (index < static_cast<uint32_t>(pixels->length())) { | 5630 if (index < static_cast<uint32_t>(pixels->length())) { |
5549 return true; | 5631 return true; |
5550 } | 5632 } |
5551 break; | 5633 break; |
5552 } | 5634 } |
| 5635 case EXTERNAL_BYTE_ELEMENTS: |
| 5636 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 5637 case EXTERNAL_SHORT_ELEMENTS: |
| 5638 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 5639 case EXTERNAL_INT_ELEMENTS: |
| 5640 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 5641 case EXTERNAL_FLOAT_ELEMENTS: { |
| 5642 ExternalArray* array = ExternalArray::cast(elements()); |
| 5643 if (index < static_cast<uint32_t>(array->length())) { |
| 5644 return true; |
| 5645 } |
| 5646 break; |
| 5647 } |
5553 case DICTIONARY_ELEMENTS: { | 5648 case DICTIONARY_ELEMENTS: { |
5554 if (element_dictionary()->FindEntry(index) | 5649 if (element_dictionary()->FindEntry(index) |
5555 != NumberDictionary::kNotFound) { | 5650 != NumberDictionary::kNotFound) { |
5556 return true; | 5651 return true; |
5557 } | 5652 } |
5558 break; | 5653 break; |
5559 } | 5654 } |
5560 default: | 5655 default: |
5561 UNREACHABLE(); | 5656 UNREACHABLE(); |
5562 break; | 5657 break; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5683 | 5778 |
5684 Object* JSObject::SetElementWithoutInterceptor(uint32_t index, Object* value) { | 5779 Object* JSObject::SetElementWithoutInterceptor(uint32_t index, Object* value) { |
5685 switch (GetElementsKind()) { | 5780 switch (GetElementsKind()) { |
5686 case FAST_ELEMENTS: | 5781 case FAST_ELEMENTS: |
5687 // Fast case. | 5782 // Fast case. |
5688 return SetFastElement(index, value); | 5783 return SetFastElement(index, value); |
5689 case PIXEL_ELEMENTS: { | 5784 case PIXEL_ELEMENTS: { |
5690 PixelArray* pixels = PixelArray::cast(elements()); | 5785 PixelArray* pixels = PixelArray::cast(elements()); |
5691 return pixels->SetValue(index, value); | 5786 return pixels->SetValue(index, value); |
5692 } | 5787 } |
| 5788 case EXTERNAL_BYTE_ELEMENTS: { |
| 5789 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
| 5790 return array->SetValue(index, value); |
| 5791 } |
| 5792 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 5793 ExternalUnsignedByteArray* array = |
| 5794 ExternalUnsignedByteArray::cast(elements()); |
| 5795 return array->SetValue(index, value); |
| 5796 } |
| 5797 case EXTERNAL_SHORT_ELEMENTS: { |
| 5798 ExternalShortArray* array = ExternalShortArray::cast(elements()); |
| 5799 return array->SetValue(index, value); |
| 5800 } |
| 5801 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 5802 ExternalUnsignedShortArray* array = |
| 5803 ExternalUnsignedShortArray::cast(elements()); |
| 5804 return array->SetValue(index, value); |
| 5805 } |
| 5806 case EXTERNAL_INT_ELEMENTS: { |
| 5807 ExternalIntArray* array = ExternalIntArray::cast(elements()); |
| 5808 return array->SetValue(index, value); |
| 5809 } |
| 5810 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 5811 ExternalUnsignedIntArray* array = |
| 5812 ExternalUnsignedIntArray::cast(elements()); |
| 5813 return array->SetValue(index, value); |
| 5814 } |
| 5815 case EXTERNAL_FLOAT_ELEMENTS: { |
| 5816 ExternalFloatArray* array = ExternalFloatArray::cast(elements()); |
| 5817 return array->SetValue(index, value); |
| 5818 } |
5693 case DICTIONARY_ELEMENTS: { | 5819 case DICTIONARY_ELEMENTS: { |
5694 // Insert element in the dictionary. | 5820 // Insert element in the dictionary. |
5695 FixedArray* elms = FixedArray::cast(elements()); | 5821 FixedArray* elms = FixedArray::cast(elements()); |
5696 NumberDictionary* dictionary = NumberDictionary::cast(elms); | 5822 NumberDictionary* dictionary = NumberDictionary::cast(elms); |
5697 | 5823 |
5698 int entry = dictionary->FindEntry(index); | 5824 int entry = dictionary->FindEntry(index); |
5699 if (entry != NumberDictionary::kNotFound) { | 5825 if (entry != NumberDictionary::kNotFound) { |
5700 Object* element = dictionary->ValueAt(entry); | 5826 Object* element = dictionary->ValueAt(entry); |
5701 PropertyDetails details = dictionary->DetailsAt(entry); | 5827 PropertyDetails details = dictionary->DetailsAt(entry); |
5702 if (details.type() == CALLBACKS) { | 5828 if (details.type() == CALLBACKS) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5800 Object* value = elms->get(index); | 5926 Object* value = elms->get(index); |
5801 if (!value->IsTheHole()) return value; | 5927 if (!value->IsTheHole()) return value; |
5802 } | 5928 } |
5803 break; | 5929 break; |
5804 } | 5930 } |
5805 case PIXEL_ELEMENTS: { | 5931 case PIXEL_ELEMENTS: { |
5806 // TODO(iposva): Add testcase and implement. | 5932 // TODO(iposva): Add testcase and implement. |
5807 UNIMPLEMENTED(); | 5933 UNIMPLEMENTED(); |
5808 break; | 5934 break; |
5809 } | 5935 } |
| 5936 case EXTERNAL_BYTE_ELEMENTS: |
| 5937 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 5938 case EXTERNAL_SHORT_ELEMENTS: |
| 5939 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 5940 case EXTERNAL_INT_ELEMENTS: |
| 5941 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 5942 case EXTERNAL_FLOAT_ELEMENTS: { |
| 5943 // TODO(kbr): Add testcase and implement. |
| 5944 UNIMPLEMENTED(); |
| 5945 break; |
| 5946 } |
5810 case DICTIONARY_ELEMENTS: { | 5947 case DICTIONARY_ELEMENTS: { |
5811 NumberDictionary* dictionary = element_dictionary(); | 5948 NumberDictionary* dictionary = element_dictionary(); |
5812 int entry = dictionary->FindEntry(index); | 5949 int entry = dictionary->FindEntry(index); |
5813 if (entry != NumberDictionary::kNotFound) { | 5950 if (entry != NumberDictionary::kNotFound) { |
5814 Object* element = dictionary->ValueAt(entry); | 5951 Object* element = dictionary->ValueAt(entry); |
5815 PropertyDetails details = dictionary->DetailsAt(entry); | 5952 PropertyDetails details = dictionary->DetailsAt(entry); |
5816 if (details.type() == CALLBACKS) { | 5953 if (details.type() == CALLBACKS) { |
5817 // Only accessors allowed as elements. | 5954 // Only accessors allowed as elements. |
5818 FixedArray* structure = FixedArray::cast(element); | 5955 FixedArray* structure = FixedArray::cast(element); |
5819 Object* getter = structure->get(kGetterIndex); | 5956 Object* getter = structure->get(kGetterIndex); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5898 break; | 6035 break; |
5899 } | 6036 } |
5900 case PIXEL_ELEMENTS: { | 6037 case PIXEL_ELEMENTS: { |
5901 PixelArray* pixels = PixelArray::cast(elements()); | 6038 PixelArray* pixels = PixelArray::cast(elements()); |
5902 if (index < static_cast<uint32_t>(pixels->length())) { | 6039 if (index < static_cast<uint32_t>(pixels->length())) { |
5903 uint8_t value = pixels->get(index); | 6040 uint8_t value = pixels->get(index); |
5904 return Smi::FromInt(value); | 6041 return Smi::FromInt(value); |
5905 } | 6042 } |
5906 break; | 6043 break; |
5907 } | 6044 } |
| 6045 case EXTERNAL_BYTE_ELEMENTS: { |
| 6046 ExternalByteArray* array = ExternalByteArray::cast(elements()); |
| 6047 if (index < static_cast<uint32_t>(array->length())) { |
| 6048 int8_t value = array->get(index); |
| 6049 return Smi::FromInt(value); |
| 6050 } |
| 6051 return Top::Throw(*Factory::NewIndexError(index)); |
| 6052 } |
| 6053 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 6054 ExternalUnsignedByteArray* array = |
| 6055 ExternalUnsignedByteArray::cast(elements()); |
| 6056 if (index < static_cast<uint32_t>(array->length())) { |
| 6057 uint8_t value = array->get(index); |
| 6058 return Smi::FromInt(value); |
| 6059 } |
| 6060 return Top::Throw(*Factory::NewIndexError(index)); |
| 6061 } |
| 6062 case EXTERNAL_SHORT_ELEMENTS: { |
| 6063 ExternalShortArray* array = ExternalShortArray::cast(elements()); |
| 6064 if (index < static_cast<uint32_t>(array->length())) { |
| 6065 int16_t value = array->get(index); |
| 6066 return Smi::FromInt(value); |
| 6067 } |
| 6068 return Top::Throw(*Factory::NewIndexError(index)); |
| 6069 } |
| 6070 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 6071 ExternalUnsignedShortArray* array = |
| 6072 ExternalUnsignedShortArray::cast(elements()); |
| 6073 if (index < static_cast<uint32_t>(array->length())) { |
| 6074 uint16_t value = array->get(index); |
| 6075 return Smi::FromInt(value); |
| 6076 } |
| 6077 return Top::Throw(*Factory::NewIndexError(index)); |
| 6078 } |
| 6079 case EXTERNAL_INT_ELEMENTS: { |
| 6080 ExternalIntArray* array = ExternalIntArray::cast(elements()); |
| 6081 if (index < static_cast<uint32_t>(array->length())) { |
| 6082 int32_t value = array->get(index); |
| 6083 return Heap::NumberFromInt32(value); |
| 6084 } |
| 6085 return Top::Throw(*Factory::NewIndexError(index)); |
| 6086 } |
| 6087 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 6088 ExternalUnsignedIntArray* array = |
| 6089 ExternalUnsignedIntArray::cast(elements()); |
| 6090 if (index < static_cast<uint32_t>(array->length())) { |
| 6091 uint32_t value = array->get(index); |
| 6092 return Heap::NumberFromUint32(value); |
| 6093 } |
| 6094 return Top::Throw(*Factory::NewIndexError(index)); |
| 6095 } |
| 6096 case EXTERNAL_FLOAT_ELEMENTS: { |
| 6097 ExternalFloatArray* array = ExternalFloatArray::cast(elements()); |
| 6098 if (index < static_cast<uint32_t>(array->length())) { |
| 6099 float value = array->get(index); |
| 6100 return Heap::AllocateHeapNumber(value); |
| 6101 } |
| 6102 return Top::Throw(*Factory::NewIndexError(index)); |
| 6103 } |
5908 case DICTIONARY_ELEMENTS: { | 6104 case DICTIONARY_ELEMENTS: { |
5909 NumberDictionary* dictionary = element_dictionary(); | 6105 NumberDictionary* dictionary = element_dictionary(); |
5910 int entry = dictionary->FindEntry(index); | 6106 int entry = dictionary->FindEntry(index); |
5911 if (entry != NumberDictionary::kNotFound) { | 6107 if (entry != NumberDictionary::kNotFound) { |
5912 Object* element = dictionary->ValueAt(entry); | 6108 Object* element = dictionary->ValueAt(entry); |
5913 PropertyDetails details = dictionary->DetailsAt(entry); | 6109 PropertyDetails details = dictionary->DetailsAt(entry); |
5914 if (details.type() == CALLBACKS) { | 6110 if (details.type() == CALLBACKS) { |
5915 // Only accessors allowed as elements. | 6111 // Only accessors allowed as elements. |
5916 FixedArray* structure = FixedArray::cast(element); | 6112 FixedArray* structure = FixedArray::cast(element); |
5917 Object* getter = structure->get(kGetterIndex); | 6113 Object* getter = structure->get(kGetterIndex); |
(...skipping 23 matching lines...) Expand all Loading... |
5941 | 6137 |
5942 switch (GetElementsKind()) { | 6138 switch (GetElementsKind()) { |
5943 case FAST_ELEMENTS: { | 6139 case FAST_ELEMENTS: { |
5944 FixedArray* elms = FixedArray::cast(elements()); | 6140 FixedArray* elms = FixedArray::cast(elements()); |
5945 capacity = elms->length(); | 6141 capacity = elms->length(); |
5946 for (int i = 0; i < capacity; i++) { | 6142 for (int i = 0; i < capacity; i++) { |
5947 if (!elms->get(i)->IsTheHole()) number_of_elements++; | 6143 if (!elms->get(i)->IsTheHole()) number_of_elements++; |
5948 } | 6144 } |
5949 break; | 6145 break; |
5950 } | 6146 } |
5951 case PIXEL_ELEMENTS: { | 6147 case PIXEL_ELEMENTS: |
| 6148 case EXTERNAL_BYTE_ELEMENTS: |
| 6149 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 6150 case EXTERNAL_SHORT_ELEMENTS: |
| 6151 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 6152 case EXTERNAL_INT_ELEMENTS: |
| 6153 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 6154 case EXTERNAL_FLOAT_ELEMENTS: { |
5952 return true; | 6155 return true; |
5953 } | 6156 } |
5954 case DICTIONARY_ELEMENTS: { | 6157 case DICTIONARY_ELEMENTS: { |
5955 NumberDictionary* dictionary = NumberDictionary::cast(elements()); | 6158 NumberDictionary* dictionary = NumberDictionary::cast(elements()); |
5956 capacity = dictionary->Capacity(); | 6159 capacity = dictionary->Capacity(); |
5957 number_of_elements = dictionary->NumberOfElements(); | 6160 number_of_elements = dictionary->NumberOfElements(); |
5958 break; | 6161 break; |
5959 } | 6162 } |
5960 default: | 6163 default: |
5961 UNREACHABLE(); | 6164 UNREACHABLE(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6165 static_cast<uint32_t>( | 6368 static_cast<uint32_t>( |
6166 Smi::cast(JSArray::cast(this)->length())->value()) : | 6369 Smi::cast(JSArray::cast(this)->length())->value()) : |
6167 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 6370 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
6168 return (index < length) && | 6371 return (index < length) && |
6169 !FixedArray::cast(elements())->get(index)->IsTheHole(); | 6372 !FixedArray::cast(elements())->get(index)->IsTheHole(); |
6170 } | 6373 } |
6171 case PIXEL_ELEMENTS: { | 6374 case PIXEL_ELEMENTS: { |
6172 PixelArray* pixels = PixelArray::cast(elements()); | 6375 PixelArray* pixels = PixelArray::cast(elements()); |
6173 return index < static_cast<uint32_t>(pixels->length()); | 6376 return index < static_cast<uint32_t>(pixels->length()); |
6174 } | 6377 } |
| 6378 case EXTERNAL_BYTE_ELEMENTS: |
| 6379 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 6380 case EXTERNAL_SHORT_ELEMENTS: |
| 6381 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 6382 case EXTERNAL_INT_ELEMENTS: |
| 6383 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 6384 case EXTERNAL_FLOAT_ELEMENTS: { |
| 6385 ExternalArray* array = ExternalArray::cast(elements()); |
| 6386 return index < static_cast<uint32_t>(array->length()); |
| 6387 } |
6175 case DICTIONARY_ELEMENTS: { | 6388 case DICTIONARY_ELEMENTS: { |
6176 return element_dictionary()->FindEntry(index) | 6389 return element_dictionary()->FindEntry(index) |
6177 != NumberDictionary::kNotFound; | 6390 != NumberDictionary::kNotFound; |
6178 } | 6391 } |
6179 default: | 6392 default: |
6180 UNREACHABLE(); | 6393 UNREACHABLE(); |
6181 break; | 6394 break; |
6182 } | 6395 } |
6183 // All possibilities have been handled above already. | 6396 // All possibilities have been handled above already. |
6184 UNREACHABLE(); | 6397 UNREACHABLE(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6385 int length = PixelArray::cast(elements())->length(); | 6598 int length = PixelArray::cast(elements())->length(); |
6386 while (counter < length) { | 6599 while (counter < length) { |
6387 if (storage != NULL) { | 6600 if (storage != NULL) { |
6388 storage->set(counter, Smi::FromInt(counter), SKIP_WRITE_BARRIER); | 6601 storage->set(counter, Smi::FromInt(counter), SKIP_WRITE_BARRIER); |
6389 } | 6602 } |
6390 counter++; | 6603 counter++; |
6391 } | 6604 } |
6392 ASSERT(!storage || storage->length() >= counter); | 6605 ASSERT(!storage || storage->length() >= counter); |
6393 break; | 6606 break; |
6394 } | 6607 } |
| 6608 case EXTERNAL_BYTE_ELEMENTS: |
| 6609 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 6610 case EXTERNAL_SHORT_ELEMENTS: |
| 6611 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 6612 case EXTERNAL_INT_ELEMENTS: |
| 6613 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 6614 case EXTERNAL_FLOAT_ELEMENTS: { |
| 6615 int length = ExternalArray::cast(elements())->length(); |
| 6616 while (counter < length) { |
| 6617 if (storage != NULL) { |
| 6618 storage->set(counter, Smi::FromInt(counter), SKIP_WRITE_BARRIER); |
| 6619 } |
| 6620 counter++; |
| 6621 } |
| 6622 ASSERT(!storage || storage->length() >= counter); |
| 6623 break; |
| 6624 } |
6395 case DICTIONARY_ELEMENTS: { | 6625 case DICTIONARY_ELEMENTS: { |
6396 if (storage != NULL) { | 6626 if (storage != NULL) { |
6397 element_dictionary()->CopyKeysTo(storage, filter); | 6627 element_dictionary()->CopyKeysTo(storage, filter); |
6398 } | 6628 } |
6399 counter = element_dictionary()->NumberOfElementsFilterAttributes(filter); | 6629 counter = element_dictionary()->NumberOfElementsFilterAttributes(filter); |
6400 break; | 6630 break; |
6401 } | 6631 } |
6402 default: | 6632 default: |
6403 UNREACHABLE(); | 6633 UNREACHABLE(); |
6404 break; | 6634 break; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6931 result_double->set_value(static_cast<double>(result)); | 7161 result_double->set_value(static_cast<double>(result)); |
6932 return result_double; | 7162 return result_double; |
6933 } | 7163 } |
6934 | 7164 |
6935 | 7165 |
6936 // Collects all defined (non-hole) and non-undefined (array) elements at | 7166 // Collects all defined (non-hole) and non-undefined (array) elements at |
6937 // the start of the elements array. | 7167 // the start of the elements array. |
6938 // If the object is in dictionary mode, it is converted to fast elements | 7168 // If the object is in dictionary mode, it is converted to fast elements |
6939 // mode. | 7169 // mode. |
6940 Object* JSObject::PrepareElementsForSort(uint32_t limit) { | 7170 Object* JSObject::PrepareElementsForSort(uint32_t limit) { |
6941 ASSERT(!HasPixelElements()); | 7171 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
6942 | 7172 |
6943 if (HasDictionaryElements()) { | 7173 if (HasDictionaryElements()) { |
6944 // Convert to fast elements containing only the existing properties. | 7174 // Convert to fast elements containing only the existing properties. |
6945 // Ordering is irrelevant, since we are going to sort anyway. | 7175 // Ordering is irrelevant, since we are going to sort anyway. |
6946 NumberDictionary* dict = element_dictionary(); | 7176 NumberDictionary* dict = element_dictionary(); |
6947 if (IsJSArray() || dict->requires_slow_elements() || | 7177 if (IsJSArray() || dict->requires_slow_elements() || |
6948 dict->max_number_key() >= limit) { | 7178 dict->max_number_key() >= limit) { |
6949 return PrepareSlowElementsForSort(limit); | 7179 return PrepareSlowElementsForSort(limit); |
6950 } | 7180 } |
6951 // Convert to fast elements. | 7181 // Convert to fast elements. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7063 // Clamp undefined to zero (default). All other types have been | 7293 // Clamp undefined to zero (default). All other types have been |
7064 // converted to a number type further up in the call chain. | 7294 // converted to a number type further up in the call chain. |
7065 ASSERT(value->IsUndefined()); | 7295 ASSERT(value->IsUndefined()); |
7066 } | 7296 } |
7067 set(index, clamped_value); | 7297 set(index, clamped_value); |
7068 } | 7298 } |
7069 return Smi::FromInt(clamped_value); | 7299 return Smi::FromInt(clamped_value); |
7070 } | 7300 } |
7071 | 7301 |
7072 | 7302 |
| 7303 template<typename ExternalArrayClass, typename ValueType> |
| 7304 static Object* ExternalArrayIntSetter(ExternalArrayClass* receiver, |
| 7305 uint32_t index, |
| 7306 Object* value) { |
| 7307 ValueType cast_value = 0; |
| 7308 if (index < static_cast<uint32_t>(receiver->length())) { |
| 7309 if (value->IsSmi()) { |
| 7310 int int_value = Smi::cast(value)->value(); |
| 7311 cast_value = static_cast<ValueType>(int_value); |
| 7312 } else if (value->IsHeapNumber()) { |
| 7313 double double_value = HeapNumber::cast(value)->value(); |
| 7314 cast_value = static_cast<ValueType>(double_value); |
| 7315 } else { |
| 7316 // Clamp undefined to zero (default). All other types have been |
| 7317 // converted to a number type further up in the call chain. |
| 7318 ASSERT(value->IsUndefined()); |
| 7319 } |
| 7320 receiver->set(index, cast_value); |
| 7321 } else { |
| 7322 return Top::Throw(*Factory::NewIndexError(index)); |
| 7323 } |
| 7324 return Heap::NumberFromInt32(cast_value); |
| 7325 } |
| 7326 |
| 7327 |
| 7328 Object* ExternalByteArray::SetValue(uint32_t index, Object* value) { |
| 7329 return ExternalArrayIntSetter<ExternalByteArray, int8_t> |
| 7330 (this, index, value); |
| 7331 } |
| 7332 |
| 7333 |
| 7334 Object* ExternalUnsignedByteArray::SetValue(uint32_t index, Object* value) { |
| 7335 return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t> |
| 7336 (this, index, value); |
| 7337 } |
| 7338 |
| 7339 |
| 7340 Object* ExternalShortArray::SetValue(uint32_t index, Object* value) { |
| 7341 return ExternalArrayIntSetter<ExternalShortArray, int16_t> |
| 7342 (this, index, value); |
| 7343 } |
| 7344 |
| 7345 |
| 7346 Object* ExternalUnsignedShortArray::SetValue(uint32_t index, Object* value) { |
| 7347 return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t> |
| 7348 (this, index, value); |
| 7349 } |
| 7350 |
| 7351 |
| 7352 Object* ExternalIntArray::SetValue(uint32_t index, Object* value) { |
| 7353 return ExternalArrayIntSetter<ExternalIntArray, int32_t> |
| 7354 (this, index, value); |
| 7355 } |
| 7356 |
| 7357 |
| 7358 Object* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) { |
| 7359 uint32_t cast_value = 0; |
| 7360 if (index < static_cast<uint32_t>(length())) { |
| 7361 if (value->IsSmi()) { |
| 7362 int int_value = Smi::cast(value)->value(); |
| 7363 cast_value = static_cast<uint32_t>(int_value); |
| 7364 } else if (value->IsHeapNumber()) { |
| 7365 double double_value = HeapNumber::cast(value)->value(); |
| 7366 cast_value = static_cast<uint32_t>(double_value); |
| 7367 } else { |
| 7368 // Clamp undefined to zero (default). All other types have been |
| 7369 // converted to a number type further up in the call chain. |
| 7370 ASSERT(value->IsUndefined()); |
| 7371 } |
| 7372 set(index, cast_value); |
| 7373 } else { |
| 7374 return Top::Throw(*Factory::NewIndexError(index)); |
| 7375 } |
| 7376 return Heap::NumberFromUint32(cast_value); |
| 7377 } |
| 7378 |
| 7379 |
| 7380 Object* ExternalFloatArray::SetValue(uint32_t index, Object* value) { |
| 7381 float cast_value = 0; |
| 7382 if (index < static_cast<uint32_t>(length())) { |
| 7383 if (value->IsSmi()) { |
| 7384 int int_value = Smi::cast(value)->value(); |
| 7385 cast_value = static_cast<float>(int_value); |
| 7386 } else if (value->IsHeapNumber()) { |
| 7387 double double_value = HeapNumber::cast(value)->value(); |
| 7388 cast_value = static_cast<float>(double_value); |
| 7389 } else { |
| 7390 // Clamp undefined to zero (default). All other types have been |
| 7391 // converted to a number type further up in the call chain. |
| 7392 ASSERT(value->IsUndefined()); |
| 7393 } |
| 7394 set(index, cast_value); |
| 7395 } else { |
| 7396 return Top::Throw(*Factory::NewIndexError(index)); |
| 7397 } |
| 7398 return Heap::AllocateHeapNumber(cast_value); |
| 7399 } |
| 7400 |
| 7401 |
7073 Object* GlobalObject::GetPropertyCell(LookupResult* result) { | 7402 Object* GlobalObject::GetPropertyCell(LookupResult* result) { |
7074 ASSERT(!HasFastProperties()); | 7403 ASSERT(!HasFastProperties()); |
7075 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 7404 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
7076 ASSERT(value->IsJSGlobalPropertyCell()); | 7405 ASSERT(value->IsJSGlobalPropertyCell()); |
7077 return value; | 7406 return value; |
7078 } | 7407 } |
7079 | 7408 |
7080 | 7409 |
7081 Object* GlobalObject::EnsurePropertyCell(String* name) { | 7410 Object* GlobalObject::EnsurePropertyCell(String* name) { |
7082 ASSERT(!HasFastProperties()); | 7411 ASSERT(!HasFastProperties()); |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7981 if (break_point_objects()->IsUndefined()) return 0; | 8310 if (break_point_objects()->IsUndefined()) return 0; |
7982 // Single beak point. | 8311 // Single beak point. |
7983 if (!break_point_objects()->IsFixedArray()) return 1; | 8312 if (!break_point_objects()->IsFixedArray()) return 1; |
7984 // Multiple break points. | 8313 // Multiple break points. |
7985 return FixedArray::cast(break_point_objects())->length(); | 8314 return FixedArray::cast(break_point_objects())->length(); |
7986 } | 8315 } |
7987 #endif | 8316 #endif |
7988 | 8317 |
7989 | 8318 |
7990 } } // namespace v8::internal | 8319 } } // namespace v8::internal |
OLD | NEW |