| 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 "conversions.h" | 7 #include "conversions.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
| 10 | 10 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return character - from <= to - from; | 370 return character - from <= to - from; |
| 371 } | 371 } |
| 372 | 372 |
| 373 | 373 |
| 374 static inline Handle<String> MakeOrFindTwoCharacterString(Isolate* isolate, | 374 static inline Handle<String> MakeOrFindTwoCharacterString(Isolate* isolate, |
| 375 uint16_t c1, | 375 uint16_t c1, |
| 376 uint16_t c2) { | 376 uint16_t c2) { |
| 377 // Numeric strings have a different hash algorithm not known by | 377 // Numeric strings have a different hash algorithm not known by |
| 378 // LookupTwoCharsStringIfExists, so we skip this step for such strings. | 378 // LookupTwoCharsStringIfExists, so we skip this step for such strings. |
| 379 if (!Between(c1, '0', '9') || !Between(c2, '0', '9')) { | 379 if (!Between(c1, '0', '9') || !Between(c2, '0', '9')) { |
| 380 String* result; | 380 Handle<String> result; |
| 381 StringTable* table = isolate->heap()->string_table(); | 381 if (StringTable::LookupTwoCharsStringIfExists(isolate, c1, c2). |
| 382 if (table->LookupTwoCharsStringIfExists(c1, c2, &result)) { | 382 ToHandle(&result)) { |
| 383 return handle(result); | 383 return result; |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 // Now we know the length is 2, we might as well make use of that fact | 387 // Now we know the length is 2, we might as well make use of that fact |
| 388 // when building the new string. | 388 // when building the new string. |
| 389 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) { | 389 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) { |
| 390 // We can do this. | 390 // We can do this. |
| 391 ASSERT(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this. | 391 ASSERT(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this. |
| 392 Handle<SeqOneByteString> str = | 392 Handle<SeqOneByteString> str = |
| 393 isolate->factory()->NewRawOneByteString(2).ToHandleChecked(); | 393 isolate->factory()->NewRawOneByteString(2).ToHandleChecked(); |
| (...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 return Handle<Object>::null(); | 2332 return Handle<Object>::null(); |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 | 2335 |
| 2336 Handle<Object> Factory::ToBoolean(bool value) { | 2336 Handle<Object> Factory::ToBoolean(bool value) { |
| 2337 return value ? true_value() : false_value(); | 2337 return value ? true_value() : false_value(); |
| 2338 } | 2338 } |
| 2339 | 2339 |
| 2340 | 2340 |
| 2341 } } // namespace v8::internal | 2341 } } // namespace v8::internal |
| OLD | NEW |