| 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 9757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9768 args.at<Object>(2), | 9768 args.at<Object>(2), |
| 9769 language_mode, | 9769 language_mode, |
| 9770 args.smi_at(4)); | 9770 args.smi_at(4)); |
| 9771 } | 9771 } |
| 9772 | 9772 |
| 9773 | 9773 |
| 9774 // Allocate a block of memory in the given space (filled with a filler). | 9774 // Allocate a block of memory in the given space (filled with a filler). |
| 9775 // Used as a fall-back for generated code when the space is full. | 9775 // Used as a fall-back for generated code when the space is full. |
| 9776 static MaybeObject* Allocate(Isolate* isolate, | 9776 static MaybeObject* Allocate(Isolate* isolate, |
| 9777 int size, | 9777 int size, |
| 9778 bool double_align, |
| 9778 AllocationSpace space) { | 9779 AllocationSpace space) { |
| 9779 Heap* heap = isolate->heap(); | 9780 Heap* heap = isolate->heap(); |
| 9780 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9781 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9781 RUNTIME_ASSERT(size > 0); | 9782 RUNTIME_ASSERT(size > 0); |
| 9782 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize()); | 9783 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize()); |
| 9783 HeapObject* allocation; | 9784 HeapObject* allocation; |
| 9784 { MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space); | 9785 { MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space); |
| 9785 if (!maybe_allocation->To(&allocation)) return maybe_allocation; | 9786 if (!maybe_allocation->To(&allocation)) return maybe_allocation; |
| 9786 } | 9787 } |
| 9787 #ifdef DEBUG | 9788 #ifdef DEBUG |
| 9788 MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address()); | 9789 MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address()); |
| 9789 ASSERT(chunk->owner()->identity() == space); | 9790 ASSERT(chunk->owner()->identity() == space); |
| 9790 #endif | 9791 #endif |
| 9791 heap->CreateFillerObjectAt(allocation->address(), size); | 9792 heap->CreateFillerObjectAt(allocation->address(), size); |
| 9792 return allocation; | 9793 return allocation; |
| 9793 } | 9794 } |
| 9794 | 9795 |
| 9795 | 9796 |
| 9796 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { | 9797 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { |
| 9797 SealHandleScope shs(isolate); | 9798 SealHandleScope shs(isolate); |
| 9798 ASSERT(args.length() == 1); | 9799 ASSERT(args.length() == 1); |
| 9799 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9800 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9800 return Allocate(isolate, size_smi->value(), NEW_SPACE); | 9801 return Allocate(isolate, size, false, NEW_SPACE); |
| 9801 } | 9802 } |
| 9802 | 9803 |
| 9803 | 9804 |
| 9804 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) { | 9805 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInTargetSpace) { |
| 9805 SealHandleScope shs(isolate); | 9806 SealHandleScope shs(isolate); |
| 9806 ASSERT(args.length() == 1); | 9807 ASSERT(args.length() == 2); |
| 9807 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9808 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9808 return Allocate(isolate, size_smi->value(), OLD_POINTER_SPACE); | 9809 CONVERT_SMI_ARG_CHECKED(flags, 1); |
| 9810 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
| 9811 AllocationSpace space = AllocateTargetSpace::decode(flags); |
| 9812 return Allocate(isolate, size, double_align, space); |
| 9809 } | 9813 } |
| 9810 | 9814 |
| 9811 | 9815 |
| 9812 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpace) { | |
| 9813 SealHandleScope shs(isolate); | |
| 9814 ASSERT(args.length() == 1); | |
| 9815 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | |
| 9816 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); | |
| 9817 } | |
| 9818 | |
| 9819 | |
| 9820 // Push an object unto an array of objects if it is not already in the | 9816 // Push an object unto an array of objects if it is not already in the |
| 9821 // array. Returns true if the element was pushed on the stack and | 9817 // array. Returns true if the element was pushed on the stack and |
| 9822 // false otherwise. | 9818 // false otherwise. |
| 9823 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9819 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
| 9824 HandleScope scope(isolate); | 9820 HandleScope scope(isolate); |
| 9825 ASSERT(args.length() == 2); | 9821 ASSERT(args.length() == 2); |
| 9826 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 9822 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 9827 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); | 9823 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); |
| 9828 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9824 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
| 9829 int length = Smi::cast(array->length())->value(); | 9825 int length = Smi::cast(array->length())->value(); |
| (...skipping 5060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14890 // Handle last resort GC and make sure to allow future allocations | 14886 // Handle last resort GC and make sure to allow future allocations |
| 14891 // to grow the heap without causing GCs (if possible). | 14887 // to grow the heap without causing GCs (if possible). |
| 14892 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14888 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14893 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14889 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14894 "Runtime::PerformGC"); | 14890 "Runtime::PerformGC"); |
| 14895 } | 14891 } |
| 14896 } | 14892 } |
| 14897 | 14893 |
| 14898 | 14894 |
| 14899 } } // namespace v8::internal | 14895 } } // namespace v8::internal |
| OLD | NEW |