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/base/bits.h" |
8 #include "src/conversions.h" | 9 #include "src/conversions.h" |
9 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
10 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 | 16 |
16 template<typename T> | 17 template<typename T> |
17 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { | 18 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (StringTable::LookupTwoCharsStringIfExists(isolate, c1, c2). | 429 if (StringTable::LookupTwoCharsStringIfExists(isolate, c1, c2). |
429 ToHandle(&result)) { | 430 ToHandle(&result)) { |
430 return result; | 431 return result; |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 // Now we know the length is 2, we might as well make use of that fact | 435 // Now we know the length is 2, we might as well make use of that fact |
435 // when building the new string. | 436 // when building the new string. |
436 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) { | 437 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) { |
437 // We can do this. | 438 // We can do this. |
438 DCHECK(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this. | 439 DCHECK(base::bits::IsPowerOfTwo32(String::kMaxOneByteCharCodeU + |
| 440 1)); // because of this. |
439 Handle<SeqOneByteString> str = | 441 Handle<SeqOneByteString> str = |
440 isolate->factory()->NewRawOneByteString(2).ToHandleChecked(); | 442 isolate->factory()->NewRawOneByteString(2).ToHandleChecked(); |
441 uint8_t* dest = str->GetChars(); | 443 uint8_t* dest = str->GetChars(); |
442 dest[0] = static_cast<uint8_t>(c1); | 444 dest[0] = static_cast<uint8_t>(c1); |
443 dest[1] = static_cast<uint8_t>(c2); | 445 dest[1] = static_cast<uint8_t>(c2); |
444 return str; | 446 return str; |
445 } else { | 447 } else { |
446 Handle<SeqTwoByteString> str = | 448 Handle<SeqTwoByteString> str = |
447 isolate->factory()->NewRawTwoByteString(2).ToHandleChecked(); | 449 isolate->factory()->NewRawTwoByteString(2).ToHandleChecked(); |
448 uc16* dest = str->GetChars(); | 450 uc16* dest = str->GetChars(); |
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 return Handle<Object>::null(); | 2387 return Handle<Object>::null(); |
2386 } | 2388 } |
2387 | 2389 |
2388 | 2390 |
2389 Handle<Object> Factory::ToBoolean(bool value) { | 2391 Handle<Object> Factory::ToBoolean(bool value) { |
2390 return value ? true_value() : false_value(); | 2392 return value ? true_value() : false_value(); |
2391 } | 2393 } |
2392 | 2394 |
2393 | 2395 |
2394 } } // namespace v8::internal | 2396 } } // namespace v8::internal |
OLD | NEW |