| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 9742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9753 ASSERT(args.length() == 1); | 9753 ASSERT(args.length() == 1); |
| 9754 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9754 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); |
| 9755 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); | 9755 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); |
| 9756 } | 9756 } |
| 9757 | 9757 |
| 9758 | 9758 |
| 9759 // Push an object unto an array of objects if it is not already in the | 9759 // Push an object unto an array of objects if it is not already in the |
| 9760 // array. Returns true if the element was pushed on the stack and | 9760 // array. Returns true if the element was pushed on the stack and |
| 9761 // false otherwise. | 9761 // false otherwise. |
| 9762 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9762 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
| 9763 SealHandleScope shs(isolate); | 9763 HandleScope scope(isolate); |
| 9764 ASSERT(args.length() == 2); | 9764 ASSERT(args.length() == 2); |
| 9765 CONVERT_ARG_CHECKED(JSArray, array, 0); | 9765 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 9766 CONVERT_ARG_CHECKED(JSReceiver, element, 1); | 9766 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); |
| 9767 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9767 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
| 9768 int length = Smi::cast(array->length())->value(); | 9768 int length = Smi::cast(array->length())->value(); |
| 9769 FixedArray* elements = FixedArray::cast(array->elements()); | 9769 FixedArray* elements = FixedArray::cast(array->elements()); |
| 9770 for (int i = 0; i < length; i++) { | 9770 for (int i = 0; i < length; i++) { |
| 9771 if (elements->get(i) == element) return isolate->heap()->false_value(); | 9771 if (elements->get(i) == *element) return isolate->heap()->false_value(); |
| 9772 } | 9772 } |
| 9773 Object* obj; | 9773 |
| 9774 // Strict not needed. Used for cycle detection in Array join implementation. | 9774 // Strict not needed. Used for cycle detection in Array join implementation. |
| 9775 { MaybeObject* maybe_obj = | 9775 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length, |
| 9776 array->SetFastElement(length, element, kNonStrictMode, true); | 9776 element, |
| 9777 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9777 kNonStrictMode, |
| 9778 } | 9778 true)); |
| 9779 return isolate->heap()->true_value(); | 9779 return isolate->heap()->true_value(); |
| 9780 } | 9780 } |
| 9781 | 9781 |
| 9782 | 9782 |
| 9783 /** | 9783 /** |
| 9784 * A simple visitor visits every element of Array's. | 9784 * A simple visitor visits every element of Array's. |
| 9785 * The backend storage can be a fixed array for fast elements case, | 9785 * The backend storage can be a fixed array for fast elements case, |
| 9786 * or a dictionary for sparse array. Since Dictionary is a subtype | 9786 * or a dictionary for sparse array. Since Dictionary is a subtype |
| 9787 * of FixedArray, the class can be used by both fast and slow cases. | 9787 * of FixedArray, the class can be used by both fast and slow cases. |
| 9788 * The second parameter of the constructor, fast_elements, specifies | 9788 * The second parameter of the constructor, fast_elements, specifies |
| (...skipping 5016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14805 // Handle last resort GC and make sure to allow future allocations | 14805 // Handle last resort GC and make sure to allow future allocations |
| 14806 // to grow the heap without causing GCs (if possible). | 14806 // to grow the heap without causing GCs (if possible). |
| 14807 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14807 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14808 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14808 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14809 "Runtime::PerformGC"); | 14809 "Runtime::PerformGC"); |
| 14810 } | 14810 } |
| 14811 } | 14811 } |
| 14812 | 14812 |
| 14813 | 14813 |
| 14814 } } // namespace v8::internal | 14814 } } // namespace v8::internal |
| OLD | NEW |