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

Side by Side Diff: src/runtime/runtime-regexp.cc

Issue 2787343002: [regexp] Revert to ZoneList usage in @@replace (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | test/mjsunit/regress/regress-707187.js » ('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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/conversions-inl.h" 10 #include "src/conversions-inl.h"
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 Handle<RegExpMatchInfo> match_info_; 1039 Handle<RegExpMatchInfo> match_info_;
1040 1040
1041 bool has_named_captures_; 1041 bool has_named_captures_;
1042 Handle<FixedArray> capture_name_map_; 1042 Handle<FixedArray> capture_name_map_;
1043 }; 1043 };
1044 1044
1045 class VectorBackedMatch : public String::Match { 1045 class VectorBackedMatch : public String::Match {
1046 public: 1046 public:
1047 VectorBackedMatch(Isolate* isolate, Handle<String> subject, 1047 VectorBackedMatch(Isolate* isolate, Handle<String> subject,
1048 Handle<String> match, int match_position, 1048 Handle<String> match, int match_position,
1049 std::vector<Handle<Object>>* captures, 1049 ZoneVector<Handle<Object>>* captures,
1050 Handle<Object> groups_obj) 1050 Handle<Object> groups_obj)
1051 : isolate_(isolate), 1051 : isolate_(isolate),
1052 match_(match), 1052 match_(match),
1053 match_position_(match_position), 1053 match_position_(match_position),
1054 captures_(captures) { 1054 captures_(captures) {
1055 subject_ = String::Flatten(subject); 1055 subject_ = String::Flatten(subject);
1056 1056
1057 DCHECK(groups_obj->IsUndefined(isolate) || groups_obj->IsJSReceiver()); 1057 DCHECK(groups_obj->IsUndefined(isolate) || groups_obj->IsJSReceiver());
1058 has_named_captures_ = !groups_obj->IsUndefined(isolate); 1058 has_named_captures_ = !groups_obj->IsUndefined(isolate);
1059 if (has_named_captures_) groups_obj_ = Handle<JSReceiver>::cast(groups_obj); 1059 if (has_named_captures_) groups_obj_ = Handle<JSReceiver>::cast(groups_obj);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 *capture_exists = true; 1098 *capture_exists = true;
1099 return Object::ToString(isolate_, capture_obj); 1099 return Object::ToString(isolate_, capture_obj);
1100 } 1100 }
1101 } 1101 }
1102 1102
1103 private: 1103 private:
1104 Isolate* isolate_; 1104 Isolate* isolate_;
1105 Handle<String> subject_; 1105 Handle<String> subject_;
1106 Handle<String> match_; 1106 Handle<String> match_;
1107 const int match_position_; 1107 const int match_position_;
1108 std::vector<Handle<Object>>* captures_; 1108 ZoneVector<Handle<Object>>* captures_;
1109 1109
1110 bool has_named_captures_; 1110 bool has_named_captures_;
1111 Handle<JSReceiver> groups_obj_; 1111 Handle<JSReceiver> groups_obj_;
1112 }; 1112 };
1113 1113
1114 // Create the groups object (see also the RegExp result creation in 1114 // Create the groups object (see also the RegExp result creation in
1115 // RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo). 1115 // RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo).
1116 Handle<JSObject> ConstructNamedCaptureGroupsObject( 1116 Handle<JSObject> ConstructNamedCaptureGroupsObject(
1117 Isolate* isolate, Handle<FixedArray> capture_map, 1117 Isolate* isolate, Handle<FixedArray> capture_map,
1118 std::function<Object*(int)> f_get_capture) { 1118 std::function<Object*(int)> f_get_capture) {
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 Handle<Object> position_obj; 1832 Handle<Object> position_obj;
1833 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1833 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1834 isolate, position_obj, 1834 isolate, position_obj,
1835 Object::GetProperty(result, factory->index_string())); 1835 Object::GetProperty(result, factory->index_string()));
1836 1836
1837 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1837 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1838 isolate, position_obj, Object::ToInteger(isolate, position_obj)); 1838 isolate, position_obj, Object::ToInteger(isolate, position_obj));
1839 const uint32_t position = 1839 const uint32_t position =
1840 std::min(PositiveNumberToUint32(*position_obj), length); 1840 std::min(PositiveNumberToUint32(*position_obj), length);
1841 1841
1842 std::vector<Handle<Object>> captures; 1842 // Do not reserve capacity since captures_length is user-controlled.
1843 captures.reserve(captures_length); 1843 ZoneVector<Handle<Object>> captures(&zone);
1844 1844
1845 for (int n = 0; n < captures_length; n++) { 1845 for (int n = 0; n < captures_length; n++) {
1846 Handle<Object> capture; 1846 Handle<Object> capture;
1847 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1847 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1848 isolate, capture, Object::GetElement(isolate, result, n)); 1848 isolate, capture, Object::GetElement(isolate, result, n));
1849 1849
1850 if (!capture->IsUndefined(isolate)) { 1850 if (!capture->IsUndefined(isolate)) {
1851 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, capture, 1851 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, capture,
1852 Object::ToString(isolate, capture)); 1852 Object::ToString(isolate, capture));
1853 } 1853 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 1942
1943 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1943 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1944 SealHandleScope shs(isolate); 1944 SealHandleScope shs(isolate);
1945 DCHECK_EQ(1, args.length()); 1945 DCHECK_EQ(1, args.length());
1946 CONVERT_ARG_CHECKED(Object, obj, 0); 1946 CONVERT_ARG_CHECKED(Object, obj, 0);
1947 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1947 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1948 } 1948 }
1949 1949
1950 } // namespace internal 1950 } // namespace internal
1951 } // namespace v8 1951 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-707187.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698