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

Unified Diff: src/factory.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: V5 (try to make gcmole happy) 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 side-by-side diff with in-line comments
Download patch
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index f7e1c746dd49f79fe31d6ffbb11aab5f24785557..bf0f729d5df56ecee14b97ff15e37292a1060f9a 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -607,7 +607,7 @@ Handle<String> Factory::NewProperSubString(Handle<String> str,
#if VERIFY_HEAP
if (FLAG_verify_heap) str->StringVerify();
#endif
- DCHECK(begin > 0 || end < str->length());
+ DCHECK(begin > 0 || end <= str->length());
Benedikt Meurer 2016/09/19 04:05:18 This still looks wrong to me. Please undo this cha
caitp 2016/09/19 16:03:05 Done.
str = String::Flatten(str);
@@ -734,6 +734,16 @@ Handle<ExternalOneByteString> Factory::NewNativeSourceString(
return external_string;
}
+Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
+ Handle<Map> map(isolate()->native_context()->string_iterator_map());
Benedikt Meurer 2016/09/19 04:05:18 Nit: Handle<Map> map(isolate()->native_context()->
caitp 2016/09/19 16:03:05 Done.
+ Handle<String> flat_string = String::Flatten(string);
+ Handle<JSStringIterator> iterator =
+ Handle<JSStringIterator>::cast(NewJSObjectFromMap(map));
+ iterator->set_string(*flat_string);
+ iterator->set_index(0);
+
+ return iterator;
+}
Handle<Symbol> Factory::NewSymbol() {
CALL_HEAP_FUNCTION(
@@ -1732,6 +1742,15 @@ Handle<JSDataView> Factory::NewJSDataView() {
JSDataView);
}
+Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value,
+ bool done) {
+ Handle<Map> map(isolate()->native_context()->iterator_result_map());
+ Handle<JSIteratorResult> js_iter_result =
+ Handle<JSIteratorResult>::cast(NewJSObjectFromMap(map));
+ js_iter_result->set_value(*value);
+ js_iter_result->set_done(*ToBoolean(done));
+ return js_iter_result;
+}
Handle<JSMap> Factory::NewJSMap() {
Handle<Map> map(isolate()->native_context()->js_map_map());

Powered by Google App Engine
This is Rietveld 408576698