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

Unified Diff: src/factory.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: V2 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..9966717704672650d0e9f631701fe3b9521a1d34 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());
caitp 2016/09/15 19:02:39 this seems to be necessary to use this for the las
Benedikt Meurer 2016/09/16 03:16:37 No that'd definitely be a bug, you'd read out of b
str = String::Flatten(str);
@@ -734,6 +734,15 @@ Handle<ExternalOneByteString> Factory::NewNativeSourceString(
return external_string;
}
+Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
+ Handle<Map> map(isolate()->native_context()->string_iterator_map());
+ Handle<JSStringIterator> iterator =
+ Handle<JSStringIterator>::cast(NewJSObjectFromMap(map));
+ iterator->set_string(*String::Flatten(string));
+ iterator->set_index(Smi::FromInt(0));
+
+ return iterator;
+}
Handle<Symbol> Factory::NewSymbol() {
CALL_HEAP_FUNCTION(
@@ -1732,6 +1741,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