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

Side by Side Diff: src/heap-inl.h

Issue 207613005: No longer OOM on invalid string length. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase + addressed nits Created 6 years, 9 months 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.cc ('k') | src/hydrogen-instructions.cc » ('j') | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (IsOneByte(t, chars)) { 131 if (IsOneByte(t, chars)) {
132 return AllocateInternalizedStringImpl<true>(t, chars, hash_field); 132 return AllocateInternalizedStringImpl<true>(t, chars, hash_field);
133 } 133 }
134 return AllocateInternalizedStringImpl<false>(t, chars, hash_field); 134 return AllocateInternalizedStringImpl<false>(t, chars, hash_field);
135 } 135 }
136 136
137 137
138 MaybeObject* Heap::AllocateOneByteInternalizedString(Vector<const uint8_t> str, 138 MaybeObject* Heap::AllocateOneByteInternalizedString(Vector<const uint8_t> str,
139 uint32_t hash_field) { 139 uint32_t hash_field) {
140 if (str.length() > String::kMaxLength) { 140 if (str.length() > String::kMaxLength) {
141 v8::internal::Heap::FatalProcessOutOfMemory("invalid string length", true); 141 return isolate()->ThrowInvalidStringLength();
142 } 142 }
143 // Compute map and object size. 143 // Compute map and object size.
144 Map* map = ascii_internalized_string_map(); 144 Map* map = ascii_internalized_string_map();
145 int size = SeqOneByteString::SizeFor(str.length()); 145 int size = SeqOneByteString::SizeFor(str.length());
146 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); 146 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED);
147 147
148 // Allocate string. 148 // Allocate string.
149 Object* result; 149 Object* result;
150 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); 150 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE);
151 if (!maybe_result->ToObject(&result)) return maybe_result; 151 if (!maybe_result->ToObject(&result)) return maybe_result;
(...skipping 12 matching lines...) Expand all
164 OS::MemCopy(answer->address() + SeqOneByteString::kHeaderSize, 164 OS::MemCopy(answer->address() + SeqOneByteString::kHeaderSize,
165 str.start(), str.length()); 165 str.start(), str.length());
166 166
167 return answer; 167 return answer;
168 } 168 }
169 169
170 170
171 MaybeObject* Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, 171 MaybeObject* Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
172 uint32_t hash_field) { 172 uint32_t hash_field) {
173 if (str.length() > String::kMaxLength) { 173 if (str.length() > String::kMaxLength) {
174 v8::internal::Heap::FatalProcessOutOfMemory("invalid string length", true); 174 return isolate()->ThrowInvalidStringLength();
175 } 175 }
176 // Compute map and object size. 176 // Compute map and object size.
177 Map* map = internalized_string_map(); 177 Map* map = internalized_string_map();
178 int size = SeqTwoByteString::SizeFor(str.length()); 178 int size = SeqTwoByteString::SizeFor(str.length());
179 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); 179 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED);
180 180
181 // Allocate string. 181 // Allocate string.
182 Object* result; 182 Object* result;
183 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); 183 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE);
184 if (!maybe_result->ToObject(&result)) return maybe_result; 184 if (!maybe_result->ToObject(&result)) return maybe_result;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 832
833 833
834 double GCTracer::SizeOfHeapObjects() { 834 double GCTracer::SizeOfHeapObjects() {
835 return (static_cast<double>(heap_->SizeOfObjects())) / MB; 835 return (static_cast<double>(heap_->SizeOfObjects())) / MB;
836 } 836 }
837 837
838 838
839 } } // namespace v8::internal 839 } } // namespace v8::internal
840 840
841 #endif // V8_HEAP_INL_H_ 841 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698