| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // Creating object copy for literals. No strict mode needed. | 165 // Creating object copy for literals. No strict mode needed. |
| 166 copy->SetProperty(key_string, result, NONE, kNonStrictMode); | 166 copy->SetProperty(key_string, result, NONE, kNonStrictMode); |
| 167 if (!maybe_result->ToObject(&result)) return maybe_result; | 167 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Deep copy local elements. | 173 // Deep copy local elements. |
| 174 // Pixel elements cannot be created using an object literal. | 174 // Pixel elements cannot be created using an object literal. |
| 175 ASSERT(!copy->HasPixelElements() && !copy->HasExternalArrayElements()); | 175 ASSERT(!copy->HasExternalArrayElements()); |
| 176 switch (copy->GetElementsKind()) { | 176 switch (copy->GetElementsKind()) { |
| 177 case JSObject::FAST_ELEMENTS: { | 177 case JSObject::FAST_ELEMENTS: { |
| 178 FixedArray* elements = FixedArray::cast(copy->elements()); | 178 FixedArray* elements = FixedArray::cast(copy->elements()); |
| 179 if (elements->map() == Heap::fixed_cow_array_map()) { | 179 if (elements->map() == Heap::fixed_cow_array_map()) { |
| 180 Counters::cow_arrays_created_runtime.Increment(); | 180 Counters::cow_arrays_created_runtime.Increment(); |
| 181 #ifdef DEBUG | 181 #ifdef DEBUG |
| 182 for (int i = 0; i < elements->length(); i++) { | 182 for (int i = 0; i < elements->length(); i++) { |
| 183 ASSERT(!elements->get(i)->IsJSObject()); | 183 ASSERT(!elements->get(i)->IsJSObject()); |
| 184 } | 184 } |
| 185 #endif | 185 #endif |
| (...skipping 8134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8320 if (index < range) { | 8320 if (index < range) { |
| 8321 indices->Add(index); | 8321 indices->Add(index); |
| 8322 } | 8322 } |
| 8323 } | 8323 } |
| 8324 } | 8324 } |
| 8325 break; | 8325 break; |
| 8326 } | 8326 } |
| 8327 default: { | 8327 default: { |
| 8328 int dense_elements_length; | 8328 int dense_elements_length; |
| 8329 switch (kind) { | 8329 switch (kind) { |
| 8330 case JSObject::PIXEL_ELEMENTS: { | 8330 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { |
| 8331 dense_elements_length = | 8331 dense_elements_length = |
| 8332 PixelArray::cast(object->elements())->length(); | 8332 ExternalPixelArray::cast(object->elements())->length(); |
| 8333 break; | 8333 break; |
| 8334 } | 8334 } |
| 8335 case JSObject::EXTERNAL_BYTE_ELEMENTS: { | 8335 case JSObject::EXTERNAL_BYTE_ELEMENTS: { |
| 8336 dense_elements_length = | 8336 dense_elements_length = |
| 8337 ExternalByteArray::cast(object->elements())->length(); | 8337 ExternalByteArray::cast(object->elements())->length(); |
| 8338 break; | 8338 break; |
| 8339 } | 8339 } |
| 8340 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 8340 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 8341 dense_elements_length = | 8341 dense_elements_length = |
| 8342 ExternalUnsignedByteArray::cast(object->elements())->length(); | 8342 ExternalUnsignedByteArray::cast(object->elements())->length(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8446 Handle<Object> element = GetElement(receiver, index); | 8446 Handle<Object> element = GetElement(receiver, index); |
| 8447 if (element.is_null()) return false; | 8447 if (element.is_null()) return false; |
| 8448 visitor->visit(index, element); | 8448 visitor->visit(index, element); |
| 8449 // Skip to next different index (i.e., omit duplicates). | 8449 // Skip to next different index (i.e., omit duplicates). |
| 8450 do { | 8450 do { |
| 8451 j++; | 8451 j++; |
| 8452 } while (j < n && indices[j] == index); | 8452 } while (j < n && indices[j] == index); |
| 8453 } | 8453 } |
| 8454 break; | 8454 break; |
| 8455 } | 8455 } |
| 8456 case JSObject::PIXEL_ELEMENTS: { | 8456 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { |
| 8457 Handle<PixelArray> pixels(PixelArray::cast(receiver->elements())); | 8457 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( |
| 8458 receiver->elements())); |
| 8458 for (uint32_t j = 0; j < length; j++) { | 8459 for (uint32_t j = 0; j < length; j++) { |
| 8459 Handle<Smi> e(Smi::FromInt(pixels->get(j))); | 8460 Handle<Smi> e(Smi::FromInt(pixels->get(j))); |
| 8460 visitor->visit(j, e); | 8461 visitor->visit(j, e); |
| 8461 } | 8462 } |
| 8462 break; | 8463 break; |
| 8463 } | 8464 } |
| 8464 case JSObject::EXTERNAL_BYTE_ELEMENTS: { | 8465 case JSObject::EXTERNAL_BYTE_ELEMENTS: { |
| 8465 IterateExternalArrayElements<ExternalByteArray, int8_t>( | 8466 IterateExternalArrayElements<ExternalByteArray, int8_t>( |
| 8466 receiver, true, true, visitor); | 8467 receiver, true, true, visitor); |
| 8467 break; | 8468 break; |
| (...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11624 } else { | 11625 } else { |
| 11625 // Handle last resort GC and make sure to allow future allocations | 11626 // Handle last resort GC and make sure to allow future allocations |
| 11626 // to grow the heap without causing GCs (if possible). | 11627 // to grow the heap without causing GCs (if possible). |
| 11627 Counters::gc_last_resort_from_js.Increment(); | 11628 Counters::gc_last_resort_from_js.Increment(); |
| 11628 Heap::CollectAllGarbage(false); | 11629 Heap::CollectAllGarbage(false); |
| 11629 } | 11630 } |
| 11630 } | 11631 } |
| 11631 | 11632 |
| 11632 | 11633 |
| 11633 } } // namespace v8::internal | 11634 } } // namespace v8::internal |
| OLD | NEW |