Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: src/runtime.cc

Issue 66723003: Make runtime new-space allocations go through Heap::AllocateRaw. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplified implementation. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9692 matching lines...) Expand 10 before | Expand all | Expand 10 after
9703 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9703 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9704 ASSERT(args[4]->IsSmi()); 9704 ASSERT(args[4]->IsSmi());
9705 return CompileGlobalEval(isolate, 9705 return CompileGlobalEval(isolate,
9706 args.at<String>(1), 9706 args.at<String>(1),
9707 args.at<Object>(2), 9707 args.at<Object>(2),
9708 language_mode, 9708 language_mode,
9709 args.smi_at(4)); 9709 args.smi_at(4));
9710 } 9710 }
9711 9711
9712 9712
9713 // Allocate a block of memory in the given space (filled with a filler).
9714 // Used as a fall-back for generated code when the space is full.
9713 static MaybeObject* Allocate(Isolate* isolate, 9715 static MaybeObject* Allocate(Isolate* isolate,
9714 int size, 9716 int size,
9715 AllocationSpace space) { 9717 AllocationSpace space) {
9716 // Allocate a block of memory in the given space (filled with a filler). 9718 Heap* heap = isolate->heap();
9717 // Use as fallback for allocation in generated code when the space
9718 // is full.
9719 SealHandleScope shs(isolate);
9720 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); 9719 RUNTIME_ASSERT(IsAligned(size, kPointerSize));
9721 RUNTIME_ASSERT(size > 0); 9720 RUNTIME_ASSERT(size > 0);
9722 Heap* heap = isolate->heap();
9723 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize()); 9721 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize());
9724 Object* allocation; 9722 HeapObject* allocation;
9725 { MaybeObject* maybe_allocation; 9723 { MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space);
9726 if (space == NEW_SPACE) { 9724 if (!maybe_allocation->To(&allocation)) return maybe_allocation;
9727 maybe_allocation = heap->new_space()->AllocateRaw(size);
9728 } else {
9729 ASSERT(space == OLD_POINTER_SPACE || space == OLD_DATA_SPACE);
9730 maybe_allocation = heap->paged_space(space)->AllocateRaw(size);
9731 }
9732 if (maybe_allocation->ToObject(&allocation)) {
9733 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
9734 }
9735 return maybe_allocation;
9736 } 9725 }
9726 #ifdef DEBUG
9727 MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address());
9728 ASSERT(chunk->owner()->identity() == space);
9729 #endif
9730 heap->CreateFillerObjectAt(allocation->address(), size);
9731 return allocation;
9737 } 9732 }
9738 9733
9739 9734
9740 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { 9735 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) {
9741 SealHandleScope shs(isolate); 9736 SealHandleScope shs(isolate);
9742 ASSERT(args.length() == 1); 9737 ASSERT(args.length() == 1);
9743 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); 9738 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
9744 return Allocate(isolate, size_smi->value(), NEW_SPACE); 9739 return Allocate(isolate, size_smi->value(), NEW_SPACE);
9745 } 9740 }
9746 9741
(...skipping 5063 matching lines...) Expand 10 before | Expand all | Expand 10 after
14810 // Handle last resort GC and make sure to allow future allocations 14805 // Handle last resort GC and make sure to allow future allocations
14811 // to grow the heap without causing GCs (if possible). 14806 // to grow the heap without causing GCs (if possible).
14812 isolate->counters()->gc_last_resort_from_js()->Increment(); 14807 isolate->counters()->gc_last_resort_from_js()->Increment();
14813 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14808 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14814 "Runtime::PerformGC"); 14809 "Runtime::PerformGC");
14815 } 14810 }
14816 } 14811 }
14817 14812
14818 14813
14819 } } // namespace v8::internal 14814 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698