| 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 "factory.h" | 5 #include "factory.h" |
| 6 | 6 |
| 7 #include "isolate-inl.h" | 7 #include "isolate-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 MaybeHandle<SeqTwoByteString> Factory::NewRawTwoByteString( | 281 MaybeHandle<SeqTwoByteString> Factory::NewRawTwoByteString( |
| 282 int length, PretenureFlag pretenure) { | 282 int length, PretenureFlag pretenure) { |
| 283 CALL_HEAP_FUNCTION( | 283 CALL_HEAP_FUNCTION( |
| 284 isolate(), | 284 isolate(), |
| 285 isolate()->heap()->AllocateRawTwoByteString(length, pretenure), | 285 isolate()->heap()->AllocateRawTwoByteString(length, pretenure), |
| 286 SeqTwoByteString); | 286 SeqTwoByteString); |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 Handle<String> Factory::LookupSingleCharacterStringFromCode(uint32_t index) { |
| 291 CALL_HEAP_FUNCTION( |
| 292 isolate(), |
| 293 isolate()->heap()->LookupSingleCharacterStringFromCode(index), |
| 294 String); |
| 295 } |
| 296 |
| 297 |
| 290 // Returns true for a character in a range. Both limits are inclusive. | 298 // Returns true for a character in a range. Both limits are inclusive. |
| 291 static inline bool Between(uint32_t character, uint32_t from, uint32_t to) { | 299 static inline bool Between(uint32_t character, uint32_t from, uint32_t to) { |
| 292 // This makes uses of the the unsigned wraparound. | 300 // This makes uses of the the unsigned wraparound. |
| 293 return character - from <= to - from; | 301 return character - from <= to - from; |
| 294 } | 302 } |
| 295 | 303 |
| 296 | 304 |
| 297 static inline Handle<String> MakeOrFindTwoCharacterString(Isolate* isolate, | 305 static inline Handle<String> MakeOrFindTwoCharacterString(Isolate* isolate, |
| 298 uint16_t c1, | 306 uint16_t c1, |
| 299 uint16_t c2) { | 307 uint16_t c2) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 int begin, | 470 int begin, |
| 463 int end) { | 471 int end) { |
| 464 #if VERIFY_HEAP | 472 #if VERIFY_HEAP |
| 465 if (FLAG_verify_heap) str->StringVerify(); | 473 if (FLAG_verify_heap) str->StringVerify(); |
| 466 #endif | 474 #endif |
| 467 ASSERT(begin > 0 || end < str->length()); | 475 ASSERT(begin > 0 || end < str->length()); |
| 468 | 476 |
| 469 int length = end - begin; | 477 int length = end - begin; |
| 470 if (length <= 0) return empty_string(); | 478 if (length <= 0) return empty_string(); |
| 471 if (length == 1) { | 479 if (length == 1) { |
| 472 return LookupSingleCharacterStringFromCode(isolate(), str->Get(begin)); | 480 return LookupSingleCharacterStringFromCode(str->Get(begin)); |
| 473 } | 481 } |
| 474 if (length == 2) { | 482 if (length == 2) { |
| 475 // Optimization for 2-byte strings often used as keys in a decompression | 483 // Optimization for 2-byte strings often used as keys in a decompression |
| 476 // dictionary. Check whether we already have the string in the string | 484 // dictionary. Check whether we already have the string in the string |
| 477 // table to prevent creation of many unnecessary strings. | 485 // table to prevent creation of many unnecessary strings. |
| 478 uint16_t c1 = str->Get(begin); | 486 uint16_t c1 = str->Get(begin); |
| 479 uint16_t c2 = str->Get(begin + 1); | 487 uint16_t c2 = str->Get(begin + 1); |
| 480 return MakeOrFindTwoCharacterString(isolate(), c1, c2); | 488 return MakeOrFindTwoCharacterString(isolate(), c1, c2); |
| 481 } | 489 } |
| 482 | 490 |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 if (name->Equals(h->infinity_string())) return infinity_value(); | 1987 if (name->Equals(h->infinity_string())) return infinity_value(); |
| 1980 return Handle<Object>::null(); | 1988 return Handle<Object>::null(); |
| 1981 } | 1989 } |
| 1982 | 1990 |
| 1983 | 1991 |
| 1984 Handle<Object> Factory::ToBoolean(bool value) { | 1992 Handle<Object> Factory::ToBoolean(bool value) { |
| 1985 return value ? true_value() : false_value(); | 1993 return value ? true_value() : false_value(); |
| 1986 } | 1994 } |
| 1987 | 1995 |
| 1988 } } // namespace v8::internal | 1996 } } // namespace v8::internal |
| OLD | NEW |