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

Side by Side Diff: src/bootstrapper.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/api.cc ('k') | src/bootstrapper.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) { 67 void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) {
68 Isolate* isolate = shared->GetIsolate(); 68 Isolate* isolate = shared->GetIsolate();
69 Factory* factory = isolate->factory(); 69 Factory* factory = isolate->factory();
70 HandleScope scope(isolate); 70 HandleScope scope(isolate);
71 int length = cache_->length(); 71 int length = cache_->length();
72 Handle<FixedArray> new_array = factory->NewFixedArray(length + 2, TENURED); 72 Handle<FixedArray> new_array = factory->NewFixedArray(length + 2, TENURED);
73 cache_->CopyTo(0, *new_array, 0, cache_->length()); 73 cache_->CopyTo(0, *new_array, 0, cache_->length());
74 cache_ = *new_array; 74 cache_ = *new_array;
75 Handle<String> str = factory->NewStringFromAscii(name, TENURED); 75 Handle<String> str = factory->NewStringFromAscii(name, TENURED);
76 ASSERT(!str.is_null());
76 cache_->set(length, *str); 77 cache_->set(length, *str);
77 cache_->set(length + 1, *shared); 78 cache_->set(length + 1, *shared);
78 Script::cast(shared->script())->set_type(Smi::FromInt(type_)); 79 Script::cast(shared->script())->set_type(Smi::FromInt(type_));
79 } 80 }
80 81
81 private: 82 private:
82 Script::Type type_; 83 Script::Type type_;
83 FixedArray* cache_; 84 FixedArray* cache_;
84 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); 85 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
85 }; 86 };
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return length_; 191 return length_;
191 } 192 }
192 private: 193 private:
193 const char* data_; 194 const char* data_;
194 size_t length_; 195 size_t length_;
195 }; 196 };
196 197
197 }} // namespace v8::internal 198 }} // namespace v8::internal
198 199
199 #endif // V8_BOOTSTRAPPER_H_ 200 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698