OLD | NEW |
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 | 253 |
254 Handle<String> Factory::NewConsString(Handle<String> first, | 254 Handle<String> Factory::NewConsString(Handle<String> first, |
255 Handle<String> second) { | 255 Handle<String> second) { |
256 CALL_HEAP_FUNCTION(isolate(), | 256 CALL_HEAP_FUNCTION(isolate(), |
257 isolate()->heap()->AllocateConsString(*first, *second), | 257 isolate()->heap()->AllocateConsString(*first, *second), |
258 String); | 258 String); |
259 } | 259 } |
260 | 260 |
261 | 261 |
| 262 template<typename SinkChar, typename StringType> |
| 263 Handle<String> ConcatStringContent(Handle<StringType> result, |
| 264 Handle<String> first, |
| 265 Handle<String> second) { |
| 266 DisallowHeapAllocation pointer_stays_valid; |
| 267 SinkChar* sink = result->GetChars(); |
| 268 String::WriteToFlat(*first, sink, 0, first->length()); |
| 269 String::WriteToFlat(*second, sink + first->length(), 0, second->length()); |
| 270 return result; |
| 271 } |
| 272 |
| 273 |
| 274 Handle<String> Factory::NewFlatConcatString(Handle<String> first, |
| 275 Handle<String> second) { |
| 276 int total_length = first->length() + second->length(); |
| 277 if (first->IsOneByteRepresentationUnderneath() && |
| 278 second->IsOneByteRepresentationUnderneath()) { |
| 279 return ConcatStringContent<uint8_t>( |
| 280 NewRawOneByteString(total_length), first, second); |
| 281 } else { |
| 282 return ConcatStringContent<uc16>( |
| 283 NewRawTwoByteString(total_length), first, second); |
| 284 } |
| 285 } |
| 286 |
| 287 |
262 Handle<String> Factory::NewSubString(Handle<String> str, | 288 Handle<String> Factory::NewSubString(Handle<String> str, |
263 int begin, | 289 int begin, |
264 int end) { | 290 int end) { |
265 CALL_HEAP_FUNCTION(isolate(), | 291 CALL_HEAP_FUNCTION(isolate(), |
266 str->SubString(begin, end), | 292 str->SubString(begin, end), |
267 String); | 293 String); |
268 } | 294 } |
269 | 295 |
270 | 296 |
271 Handle<String> Factory::NewProperSubString(Handle<String> str, | 297 Handle<String> Factory::NewProperSubString(Handle<String> str, |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 return Handle<Object>::null(); | 1598 return Handle<Object>::null(); |
1573 } | 1599 } |
1574 | 1600 |
1575 | 1601 |
1576 Handle<Object> Factory::ToBoolean(bool value) { | 1602 Handle<Object> Factory::ToBoolean(bool value) { |
1577 return value ? true_value() : false_value(); | 1603 return value ? true_value() : false_value(); |
1578 } | 1604 } |
1579 | 1605 |
1580 | 1606 |
1581 } } // namespace v8::internal | 1607 } } // namespace v8::internal |
OLD | NEW |