OLD | NEW |
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 decoder->WriteUtf16(data, utf16_length); | 263 decoder->WriteUtf16(data, utf16_length); |
264 return result; | 264 return result; |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, | 268 MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, |
269 PretenureFlag pretenure) { | 269 PretenureFlag pretenure) { |
270 int length = string.length(); | 270 int length = string.length(); |
271 const uc16* start = string.start(); | 271 const uc16* start = string.start(); |
272 if (String::IsOneByte(start, length)) { | 272 if (String::IsOneByte(start, length)) { |
| 273 if (length == 1) return LookupSingleCharacterStringFromCode(string[0]); |
273 Handle<SeqOneByteString> result; | 274 Handle<SeqOneByteString> result; |
274 ASSIGN_RETURN_ON_EXCEPTION( | 275 ASSIGN_RETURN_ON_EXCEPTION( |
275 isolate(), | 276 isolate(), |
276 result, | 277 result, |
277 NewRawOneByteString(length, pretenure), | 278 NewRawOneByteString(length, pretenure), |
278 String); | 279 String); |
279 CopyChars(result->GetChars(), start, length); | 280 CopyChars(result->GetChars(), start, length); |
280 return result; | 281 return result; |
281 } else { | 282 } else { |
282 Handle<SeqTwoByteString> result; | 283 Handle<SeqTwoByteString> result; |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 return Handle<Object>::null(); | 2366 return Handle<Object>::null(); |
2366 } | 2367 } |
2367 | 2368 |
2368 | 2369 |
2369 Handle<Object> Factory::ToBoolean(bool value) { | 2370 Handle<Object> Factory::ToBoolean(bool value) { |
2370 return value ? true_value() : false_value(); | 2371 return value ? true_value() : false_value(); |
2371 } | 2372 } |
2372 | 2373 |
2373 | 2374 |
2374 } } // namespace v8::internal | 2375 } } // namespace v8::internal |
OLD | NEW |