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

Side by Side Diff: src/factory.cc

Issue 484703002: Make internalized string parser in JSON.parse GC-safe (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/factory.h ('k') | src/objects.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 180
181 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) { 181 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) {
182 OneByteStringKey key(string, isolate()->heap()->HashSeed()); 182 OneByteStringKey key(string, isolate()->heap()->HashSeed());
183 return InternalizeStringWithKey(&key); 183 return InternalizeStringWithKey(&key);
184 } 184 }
185 185
186 186
187 Handle<String> Factory::InternalizeOneByteString( 187 Handle<String> Factory::InternalizeOneByteString(
188 Handle<SeqOneByteString> string, int from, int length) { 188 Handle<SeqOneByteString> string, int from, int length) {
189 SubStringKey<uint8_t> key(string, from, length); 189 SeqOneByteSubStringKey key(string, from, length);
190 return InternalizeStringWithKey(&key); 190 return InternalizeStringWithKey(&key);
191 } 191 }
192 192
193 193
194 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) { 194 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) {
195 TwoByteStringKey key(string, isolate()->heap()->HashSeed()); 195 TwoByteStringKey key(string, isolate()->heap()->HashSeed());
196 return InternalizeStringWithKey(&key); 196 return InternalizeStringWithKey(&key);
197 } 197 }
198 198
199 199
200 template<class StringTableKey> 200 template<class StringTableKey>
201 Handle<String> Factory::InternalizeStringWithKey(StringTableKey* key) { 201 Handle<String> Factory::InternalizeStringWithKey(StringTableKey* key) {
202 return StringTable::LookupKey(isolate(), key); 202 return StringTable::LookupKey(isolate(), key);
203 } 203 }
204 204
205 205
206 template Handle<String> Factory::InternalizeStringWithKey<
207 SubStringKey<uint8_t> > (SubStringKey<uint8_t>* key);
208 template Handle<String> Factory::InternalizeStringWithKey<
209 SubStringKey<uint16_t> > (SubStringKey<uint16_t>* key);
210
211
212 MaybeHandle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string, 206 MaybeHandle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string,
213 PretenureFlag pretenure) { 207 PretenureFlag pretenure) {
214 int length = string.length(); 208 int length = string.length();
215 if (length == 1) return LookupSingleCharacterStringFromCode(string[0]); 209 if (length == 1) return LookupSingleCharacterStringFromCode(string[0]);
216 Handle<SeqOneByteString> result; 210 Handle<SeqOneByteString> result;
217 ASSIGN_RETURN_ON_EXCEPTION( 211 ASSIGN_RETURN_ON_EXCEPTION(
218 isolate(), 212 isolate(),
219 result, 213 result,
220 NewRawOneByteString(string.length(), pretenure), 214 NewRawOneByteString(string.length(), pretenure),
221 String); 215 String);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 MUST_USE_RESULT Handle<String> Factory::NewOneByteInternalizedString( 300 MUST_USE_RESULT Handle<String> Factory::NewOneByteInternalizedString(
307 Vector<const uint8_t> str, 301 Vector<const uint8_t> str,
308 uint32_t hash_field) { 302 uint32_t hash_field) {
309 CALL_HEAP_FUNCTION( 303 CALL_HEAP_FUNCTION(
310 isolate(), 304 isolate(),
311 isolate()->heap()->AllocateOneByteInternalizedString(str, hash_field), 305 isolate()->heap()->AllocateOneByteInternalizedString(str, hash_field),
312 String); 306 String);
313 } 307 }
314 308
315 309
310 MUST_USE_RESULT Handle<String> Factory::NewOneByteInternalizedSubString(
311 Handle<SeqOneByteString> string, int offset, int length,
312 uint32_t hash_field) {
313 CALL_HEAP_FUNCTION(
314 isolate(), isolate()->heap()->AllocateOneByteInternalizedString(
315 Vector<const uint8_t>(string->GetChars() + offset, length),
316 hash_field),
317 String);
318 }
319
320
316 MUST_USE_RESULT Handle<String> Factory::NewTwoByteInternalizedString( 321 MUST_USE_RESULT Handle<String> Factory::NewTwoByteInternalizedString(
317 Vector<const uc16> str, 322 Vector<const uc16> str,
318 uint32_t hash_field) { 323 uint32_t hash_field) {
319 CALL_HEAP_FUNCTION( 324 CALL_HEAP_FUNCTION(
320 isolate(), 325 isolate(),
321 isolate()->heap()->AllocateTwoByteInternalizedString(str, hash_field), 326 isolate()->heap()->AllocateTwoByteInternalizedString(str, hash_field),
322 String); 327 String);
323 } 328 }
324 329
325 330
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 return Handle<Object>::null(); 2379 return Handle<Object>::null();
2375 } 2380 }
2376 2381
2377 2382
2378 Handle<Object> Factory::ToBoolean(bool value) { 2383 Handle<Object> Factory::ToBoolean(bool value) {
2379 return value ? true_value() : false_value(); 2384 return value ? true_value() : false_value();
2380 } 2385 }
2381 2386
2382 2387
2383 } } // namespace v8::internal 2388 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698