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

Side by Side Diff: src/factory.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: 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
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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 Handle<Map> map = native_source_string_map(); 727 Handle<Map> map = native_source_string_map();
728 Handle<ExternalOneByteString> external_string = 728 Handle<ExternalOneByteString> external_string =
729 New<ExternalOneByteString>(map, OLD_SPACE); 729 New<ExternalOneByteString>(map, OLD_SPACE);
730 external_string->set_length(static_cast<int>(length)); 730 external_string->set_length(static_cast<int>(length));
731 external_string->set_hash_field(String::kEmptyHashField); 731 external_string->set_hash_field(String::kEmptyHashField);
732 external_string->set_resource(resource); 732 external_string->set_resource(resource);
733 733
734 return external_string; 734 return external_string;
735 } 735 }
736 736
737 Handle<JSStringIterator> Factory::NewJSStringIterator() {
738 Handle<Map> map(isolate()->native_context()->string_iterator_map());
739 CALL_HEAP_FUNCTION(isolate(),
740 isolate()->heap()->AllocateJSObjectFromMap(*map),
741 JSStringIterator);
742 }
743
744 Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
745 Handle<JSStringIterator> iterator = NewJSStringIterator();
746 iterator->set_string(*String::Flatten(string));
Benedikt Meurer 2016/09/15 17:34:33 I'm not sure that GCmole will like this.
747 iterator->set_index(Smi::FromInt(0));
748
749 return iterator;
750 }
737 751
738 Handle<Symbol> Factory::NewSymbol() { 752 Handle<Symbol> Factory::NewSymbol() {
739 CALL_HEAP_FUNCTION( 753 CALL_HEAP_FUNCTION(
740 isolate(), 754 isolate(),
741 isolate()->heap()->AllocateSymbol(), 755 isolate()->heap()->AllocateSymbol(),
742 Symbol); 756 Symbol);
743 } 757 }
744 758
745 759
746 Handle<Symbol> Factory::NewPrivateSymbol() { 760 Handle<Symbol> Factory::NewPrivateSymbol() {
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 1739
1726 Handle<JSDataView> Factory::NewJSDataView() { 1740 Handle<JSDataView> Factory::NewJSDataView() {
1727 Handle<JSFunction> data_view_fun( 1741 Handle<JSFunction> data_view_fun(
1728 isolate()->native_context()->data_view_fun()); 1742 isolate()->native_context()->data_view_fun());
1729 CALL_HEAP_FUNCTION( 1743 CALL_HEAP_FUNCTION(
1730 isolate(), 1744 isolate(),
1731 isolate()->heap()->AllocateJSObject(*data_view_fun), 1745 isolate()->heap()->AllocateJSObject(*data_view_fun),
1732 JSDataView); 1746 JSDataView);
1733 } 1747 }
1734 1748
1749 Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value,
1750 bool done) {
1751 Handle<Map> map(isolate()->native_context()->iterator_result_map());
1752 Handle<JSIteratorResult> js_iter_result =
1753 Handle<JSIteratorResult>::cast(NewJSObjectFromMap(map));
1754 JSIteratorResult::Initialize(js_iter_result, value, ToBoolean(done));
1755 return js_iter_result;
1756 }
1735 1757
1736 Handle<JSMap> Factory::NewJSMap() { 1758 Handle<JSMap> Factory::NewJSMap() {
1737 Handle<Map> map(isolate()->native_context()->js_map_map()); 1759 Handle<Map> map(isolate()->native_context()->js_map_map());
1738 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); 1760 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map));
1739 JSMap::Initialize(js_map, isolate()); 1761 JSMap::Initialize(js_map, isolate());
1740 return js_map; 1762 return js_map;
1741 } 1763 }
1742 1764
1743 1765
1744 Handle<JSSet> Factory::NewJSSet() { 1766 Handle<JSSet> Factory::NewJSSet() {
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 Handle<AccessorInfo> prototype = 2553 Handle<AccessorInfo> prototype =
2532 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2554 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2533 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2555 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2534 prototype, attribs); 2556 prototype, attribs);
2535 map->AppendDescriptor(&d); 2557 map->AppendDescriptor(&d);
2536 } 2558 }
2537 } 2559 }
2538 2560
2539 } // namespace internal 2561 } // namespace internal
2540 } // namespace v8 2562 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698