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

Side by Side Diff: src/factory.cc

Issue 140953002: Refactor string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add virtual for real Created 6 years, 11 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/heap.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { 200 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() {
201 CALL_HEAP_FUNCTION(isolate(), 201 CALL_HEAP_FUNCTION(isolate(),
202 isolate()->heap()->AllocateTypeFeedbackInfo(), 202 isolate()->heap()->AllocateTypeFeedbackInfo(),
203 TypeFeedbackInfo); 203 TypeFeedbackInfo);
204 } 204 }
205 205
206 206
207 // Internalized strings are created in the old generation (data space). 207 // Internalized strings are created in the old generation (data space).
208 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { 208 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
209 CALL_HEAP_FUNCTION(isolate(), 209 Utf8StringKey key(string, isolate()->heap()->HashSeed());
210 isolate()->heap()->InternalizeUtf8String(string), 210 return InternalizeStringWithKey(&key);
211 String);
212 } 211 }
213 212
214 213
215 // Internalized strings are created in the old generation (data space). 214 // Internalized strings are created in the old generation (data space).
216 Handle<String> Factory::InternalizeString(Handle<String> string) { 215 Handle<String> Factory::InternalizeString(Handle<String> string) {
217 CALL_HEAP_FUNCTION(isolate(), 216 CALL_HEAP_FUNCTION(isolate(),
218 isolate()->heap()->InternalizeString(*string), 217 isolate()->heap()->InternalizeString(*string),
219 String); 218 String);
220 } 219 }
221 220
222 221
223 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) { 222 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) {
224 CALL_HEAP_FUNCTION(isolate(), 223 OneByteStringKey key(string, isolate()->heap()->HashSeed());
225 isolate()->heap()->InternalizeOneByteString(string), 224 return InternalizeStringWithKey(&key);
226 String);
227 } 225 }
228 226
229 227
230 Handle<String> Factory::InternalizeOneByteString( 228 Handle<String> Factory::InternalizeOneByteString(
231 Handle<SeqOneByteString> string, int from, int length) { 229 Handle<SeqOneByteString> string, int from, int length) {
232 CALL_HEAP_FUNCTION(isolate(), 230 SubStringOneByteStringKey key(string, from, length);
233 isolate()->heap()->InternalizeOneByteString( 231 return InternalizeStringWithKey(&key);
234 string, from, length),
235 String);
236 } 232 }
237 233
238 234
239 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) { 235 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) {
236 TwoByteStringKey key(string, isolate()->heap()->HashSeed());
237 return InternalizeStringWithKey(&key);
238 }
239
240
241 template<class StringTableKey>
242 Handle<String> Factory::InternalizeStringWithKey(StringTableKey* key) {
240 CALL_HEAP_FUNCTION(isolate(), 243 CALL_HEAP_FUNCTION(isolate(),
241 isolate()->heap()->InternalizeTwoByteString(string), 244 isolate()->heap()->InternalizeStringWithKey(key),
242 String); 245 String);
243 } 246 }
244 247
245 248
246 Handle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string, 249 Handle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string,
247 PretenureFlag pretenure) { 250 PretenureFlag pretenure) {
248 CALL_HEAP_FUNCTION( 251 CALL_HEAP_FUNCTION(
249 isolate(), 252 isolate(),
250 isolate()->heap()->AllocateStringFromOneByte(string, pretenure), 253 isolate()->heap()->AllocateStringFromOneByte(string, pretenure),
251 String); 254 String);
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 return Handle<Object>::null(); 2010 return Handle<Object>::null();
2008 } 2011 }
2009 2012
2010 2013
2011 Handle<Object> Factory::ToBoolean(bool value) { 2014 Handle<Object> Factory::ToBoolean(bool value) {
2012 return value ? true_value() : false_value(); 2015 return value ? true_value() : false_value();
2013 } 2016 }
2014 2017
2015 2018
2016 } } // namespace v8::internal 2019 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698