Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: src/factory.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: V8 (rebase + fix bytecode expectations) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/factory.h ('k') | src/heap/objects-visiting.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 DisallowHeapAllocation no_gc; 592 DisallowHeapAllocation no_gc;
593 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); 593 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
594 594
595 result->set_hash_field(String::kEmptyHashField); 595 result->set_hash_field(String::kEmptyHashField);
596 result->set_length(length); 596 result->set_length(length);
597 result->set_first(*left, mode); 597 result->set_first(*left, mode);
598 result->set_second(*right, mode); 598 result->set_second(*right, mode);
599 return result; 599 return result;
600 } 600 }
601 601
602 Handle<String> Factory::NewSurrogatePairString(uint16_t lead, uint16_t trail) {
603 DCHECK_GE(lead, 0xD800);
604 DCHECK_LE(lead, 0xDBFF);
605 DCHECK_GE(trail, 0xDC00);
606 DCHECK_LE(trail, 0xDFFF);
607
608 Handle<SeqTwoByteString> str =
609 isolate()->factory()->NewRawTwoByteString(2).ToHandleChecked();
610 uc16* dest = str->GetChars();
611 dest[0] = lead;
612 dest[1] = trail;
613 return str;
614 }
602 615
603 Handle<String> Factory::NewProperSubString(Handle<String> str, 616 Handle<String> Factory::NewProperSubString(Handle<String> str,
604 int begin, 617 int begin,
605 int end) { 618 int end) {
606 #if VERIFY_HEAP 619 #if VERIFY_HEAP
607 if (FLAG_verify_heap) str->StringVerify(); 620 if (FLAG_verify_heap) str->StringVerify();
608 #endif 621 #endif
609 DCHECK(begin > 0 || end < str->length()); 622 DCHECK(begin > 0 || end < str->length());
610 623
611 str = String::Flatten(str); 624 str = String::Flatten(str);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 Handle<Map> map = native_source_string_map(); 739 Handle<Map> map = native_source_string_map();
727 Handle<ExternalOneByteString> external_string = 740 Handle<ExternalOneByteString> external_string =
728 New<ExternalOneByteString>(map, OLD_SPACE); 741 New<ExternalOneByteString>(map, OLD_SPACE);
729 external_string->set_length(static_cast<int>(length)); 742 external_string->set_length(static_cast<int>(length));
730 external_string->set_hash_field(String::kEmptyHashField); 743 external_string->set_hash_field(String::kEmptyHashField);
731 external_string->set_resource(resource); 744 external_string->set_resource(resource);
732 745
733 return external_string; 746 return external_string;
734 } 747 }
735 748
749 Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
750 Handle<Map> map(isolate()->native_context()->string_iterator_map(),
751 isolate());
752 Handle<String> flat_string = String::Flatten(string);
753 Handle<JSStringIterator> iterator =
754 Handle<JSStringIterator>::cast(NewJSObjectFromMap(map));
755 iterator->set_string(*flat_string);
756 iterator->set_index(0);
757
758 return iterator;
759 }
736 760
737 Handle<Symbol> Factory::NewSymbol() { 761 Handle<Symbol> Factory::NewSymbol() {
738 CALL_HEAP_FUNCTION( 762 CALL_HEAP_FUNCTION(
739 isolate(), 763 isolate(),
740 isolate()->heap()->AllocateSymbol(), 764 isolate()->heap()->AllocateSymbol(),
741 Symbol); 765 Symbol);
742 } 766 }
743 767
744 768
745 Handle<Symbol> Factory::NewPrivateSymbol() { 769 Handle<Symbol> Factory::NewPrivateSymbol() {
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1781
1758 Handle<JSDataView> Factory::NewJSDataView() { 1782 Handle<JSDataView> Factory::NewJSDataView() {
1759 Handle<JSFunction> data_view_fun( 1783 Handle<JSFunction> data_view_fun(
1760 isolate()->native_context()->data_view_fun()); 1784 isolate()->native_context()->data_view_fun());
1761 CALL_HEAP_FUNCTION( 1785 CALL_HEAP_FUNCTION(
1762 isolate(), 1786 isolate(),
1763 isolate()->heap()->AllocateJSObject(*data_view_fun), 1787 isolate()->heap()->AllocateJSObject(*data_view_fun),
1764 JSDataView); 1788 JSDataView);
1765 } 1789 }
1766 1790
1791 Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value,
1792 bool done) {
1793 Handle<Map> map(isolate()->native_context()->iterator_result_map());
1794 Handle<JSIteratorResult> js_iter_result =
1795 Handle<JSIteratorResult>::cast(NewJSObjectFromMap(map));
1796 js_iter_result->set_value(*value);
1797 js_iter_result->set_done(*ToBoolean(done));
1798 return js_iter_result;
1799 }
1767 1800
1768 Handle<JSMap> Factory::NewJSMap() { 1801 Handle<JSMap> Factory::NewJSMap() {
1769 Handle<Map> map(isolate()->native_context()->js_map_map()); 1802 Handle<Map> map(isolate()->native_context()->js_map_map());
1770 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); 1803 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map));
1771 JSMap::Initialize(js_map, isolate()); 1804 JSMap::Initialize(js_map, isolate());
1772 return js_map; 1805 return js_map;
1773 } 1806 }
1774 1807
1775 1808
1776 Handle<JSSet> Factory::NewJSSet() { 1809 Handle<JSSet> Factory::NewJSSet() {
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 Handle<AccessorInfo> prototype = 2598 Handle<AccessorInfo> prototype =
2566 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2599 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2567 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2600 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2568 prototype, attribs); 2601 prototype, attribs);
2569 map->AppendDescriptor(&d); 2602 map->AppendDescriptor(&d);
2570 } 2603 }
2571 } 2604 }
2572 2605
2573 } // namespace internal 2606 } // namespace internal
2574 } // namespace v8 2607 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap/objects-visiting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698