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

Side by Side Diff: src/runtime.cc

Issue 5746005: Fix incorrect assumption about young/old space allocation in... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years 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 | « no previous file | 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 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 4671 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 int worst_case_length = length * kJsonQuoteWorstCaseBlowup + kSpaceForQuotes; 4682 int worst_case_length = length * kJsonQuoteWorstCaseBlowup + kSpaceForQuotes;
4683 if (worst_case_length > kMaxGuaranteedNewSpaceString) { 4683 if (worst_case_length > kMaxGuaranteedNewSpaceString) {
4684 return SlowQuoteJsonString<Char, StringType>(characters); 4684 return SlowQuoteJsonString<Char, StringType>(characters);
4685 } 4685 }
4686 4686
4687 MaybeObject* new_alloc = AllocateRawString<StringType>(worst_case_length); 4687 MaybeObject* new_alloc = AllocateRawString<StringType>(worst_case_length);
4688 Object* new_object; 4688 Object* new_object;
4689 if (!new_alloc->ToObject(&new_object)) { 4689 if (!new_alloc->ToObject(&new_object)) {
4690 return new_alloc; 4690 return new_alloc;
4691 } 4691 }
4692 if (!Heap::new_space()->Contains(new_object)) {
4693 // Even if our string is small enough to fit in new space we still have to
4694 // handle it being allocated in old space as may happen in the third
4695 // attempt. See CALL_AND_RETRY in heap-inl.h and similar code in
4696 // CEntryStub::GenerateCore.
4697 return SlowQuoteJsonString<Char, StringType>(characters);
4698 }
4692 StringType* new_string = StringType::cast(new_object); 4699 StringType* new_string = StringType::cast(new_object);
4693 ASSERT(Heap::new_space()->Contains(new_string)); 4700 ASSERT(Heap::new_space()->Contains(new_string));
4694 4701
4695 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize); 4702 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize);
4696 Char* write_cursor = reinterpret_cast<Char*>( 4703 Char* write_cursor = reinterpret_cast<Char*>(
4697 new_string->address() + SeqAsciiString::kHeaderSize); 4704 new_string->address() + SeqAsciiString::kHeaderSize);
4698 *(write_cursor++) = '"'; 4705 *(write_cursor++) = '"';
4699 4706
4700 const Char* read_cursor = characters.start(); 4707 const Char* read_cursor = characters.start();
4701 const Char* end = read_cursor + length; 4708 const Char* end = read_cursor + length;
(...skipping 6076 matching lines...) Expand 10 before | Expand all | Expand 10 after
10778 } else { 10785 } else {
10779 // Handle last resort GC and make sure to allow future allocations 10786 // Handle last resort GC and make sure to allow future allocations
10780 // to grow the heap without causing GCs (if possible). 10787 // to grow the heap without causing GCs (if possible).
10781 Counters::gc_last_resort_from_js.Increment(); 10788 Counters::gc_last_resort_from_js.Increment();
10782 Heap::CollectAllGarbage(false); 10789 Heap::CollectAllGarbage(false);
10783 } 10790 }
10784 } 10791 }
10785 10792
10786 10793
10787 } } // namespace v8::internal 10794 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698