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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 DisallowHeapAllocation no_gc; | 593 DisallowHeapAllocation no_gc; |
594 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 594 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
595 | 595 |
596 result->set_hash_field(String::kEmptyHashField); | 596 result->set_hash_field(String::kEmptyHashField); |
597 result->set_length(length); | 597 result->set_length(length); |
598 result->set_first(*left, mode); | 598 result->set_first(*left, mode); |
599 result->set_second(*right, mode); | 599 result->set_second(*right, mode); |
600 return result; | 600 return result; |
601 } | 601 } |
602 | 602 |
| 603 Handle<String> Factory::NewSurrogatePairString(uint16_t lead, uint16_t trail) { |
| 604 DCHECK_GE(lead, 0xD800); |
| 605 DCHECK_LE(lead, 0xDBFF); |
| 606 DCHECK_GE(trail, 0xDC00); |
| 607 DCHECK_LE(trail, 0xDFFF); |
| 608 |
| 609 Handle<SeqTwoByteString> str = |
| 610 isolate()->factory()->NewRawTwoByteString(2).ToHandleChecked(); |
| 611 uc16* dest = str->GetChars(); |
| 612 dest[0] = lead; |
| 613 dest[1] = trail; |
| 614 return str; |
| 615 } |
603 | 616 |
604 Handle<String> Factory::NewProperSubString(Handle<String> str, | 617 Handle<String> Factory::NewProperSubString(Handle<String> str, |
605 int begin, | 618 int begin, |
606 int end) { | 619 int end) { |
607 #if VERIFY_HEAP | 620 #if VERIFY_HEAP |
608 if (FLAG_verify_heap) str->StringVerify(); | 621 if (FLAG_verify_heap) str->StringVerify(); |
609 #endif | 622 #endif |
610 DCHECK(begin > 0 || end < str->length()); | 623 DCHECK(begin > 0 || end < str->length()); |
611 | 624 |
612 str = String::Flatten(str); | 625 str = String::Flatten(str); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 Handle<Map> map = native_source_string_map(); | 740 Handle<Map> map = native_source_string_map(); |
728 Handle<ExternalOneByteString> external_string = | 741 Handle<ExternalOneByteString> external_string = |
729 New<ExternalOneByteString>(map, OLD_SPACE); | 742 New<ExternalOneByteString>(map, OLD_SPACE); |
730 external_string->set_length(static_cast<int>(length)); | 743 external_string->set_length(static_cast<int>(length)); |
731 external_string->set_hash_field(String::kEmptyHashField); | 744 external_string->set_hash_field(String::kEmptyHashField); |
732 external_string->set_resource(resource); | 745 external_string->set_resource(resource); |
733 | 746 |
734 return external_string; | 747 return external_string; |
735 } | 748 } |
736 | 749 |
| 750 Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) { |
| 751 Handle<Map> map(isolate()->native_context()->string_iterator_map(), |
| 752 isolate()); |
| 753 Handle<String> flat_string = String::Flatten(string); |
| 754 Handle<JSStringIterator> iterator = |
| 755 Handle<JSStringIterator>::cast(NewJSObjectFromMap(map)); |
| 756 iterator->set_string(*flat_string); |
| 757 iterator->set_index(0); |
| 758 |
| 759 return iterator; |
| 760 } |
737 | 761 |
738 Handle<Symbol> Factory::NewSymbol() { | 762 Handle<Symbol> Factory::NewSymbol() { |
739 CALL_HEAP_FUNCTION( | 763 CALL_HEAP_FUNCTION( |
740 isolate(), | 764 isolate(), |
741 isolate()->heap()->AllocateSymbol(), | 765 isolate()->heap()->AllocateSymbol(), |
742 Symbol); | 766 Symbol); |
743 } | 767 } |
744 | 768 |
745 | 769 |
746 Handle<Symbol> Factory::NewPrivateSymbol() { | 770 Handle<Symbol> Factory::NewPrivateSymbol() { |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 | 1749 |
1726 Handle<JSDataView> Factory::NewJSDataView() { | 1750 Handle<JSDataView> Factory::NewJSDataView() { |
1727 Handle<JSFunction> data_view_fun( | 1751 Handle<JSFunction> data_view_fun( |
1728 isolate()->native_context()->data_view_fun()); | 1752 isolate()->native_context()->data_view_fun()); |
1729 CALL_HEAP_FUNCTION( | 1753 CALL_HEAP_FUNCTION( |
1730 isolate(), | 1754 isolate(), |
1731 isolate()->heap()->AllocateJSObject(*data_view_fun), | 1755 isolate()->heap()->AllocateJSObject(*data_view_fun), |
1732 JSDataView); | 1756 JSDataView); |
1733 } | 1757 } |
1734 | 1758 |
| 1759 Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value, |
| 1760 bool done) { |
| 1761 Handle<Map> map(isolate()->native_context()->iterator_result_map()); |
| 1762 Handle<JSIteratorResult> js_iter_result = |
| 1763 Handle<JSIteratorResult>::cast(NewJSObjectFromMap(map)); |
| 1764 js_iter_result->set_value(*value); |
| 1765 js_iter_result->set_done(*ToBoolean(done)); |
| 1766 return js_iter_result; |
| 1767 } |
1735 | 1768 |
1736 Handle<JSMap> Factory::NewJSMap() { | 1769 Handle<JSMap> Factory::NewJSMap() { |
1737 Handle<Map> map(isolate()->native_context()->js_map_map()); | 1770 Handle<Map> map(isolate()->native_context()->js_map_map()); |
1738 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); | 1771 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); |
1739 JSMap::Initialize(js_map, isolate()); | 1772 JSMap::Initialize(js_map, isolate()); |
1740 return js_map; | 1773 return js_map; |
1741 } | 1774 } |
1742 | 1775 |
1743 | 1776 |
1744 Handle<JSSet> Factory::NewJSSet() { | 1777 Handle<JSSet> Factory::NewJSSet() { |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 Handle<AccessorInfo> prototype = | 2564 Handle<AccessorInfo> prototype = |
2532 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2565 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2533 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2566 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2534 prototype, attribs); | 2567 prototype, attribs); |
2535 map->AppendDescriptor(&d); | 2568 map->AppendDescriptor(&d); |
2536 } | 2569 } |
2537 } | 2570 } |
2538 | 2571 |
2539 } // namespace internal | 2572 } // namespace internal |
2540 } // namespace v8 | 2573 } // namespace v8 |
OLD | NEW |