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

Unified Diff: src/runtime/runtime-regexp.cc

Issue 2299753002: Made zone segments aligned in memory and included a pointer to the zone in the header. Larger objec…
Patch Set: Added a zone segment pool for small segments to avoid frequent sys calls 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
« no previous file with comments | « src/list.h ('k') | src/zone.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-regexp.cc
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index b36e5e66cbae17b447958a05c6ef192a94197272..70e75406819a12ff052efd8b7fd058b106df15f6 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -389,12 +389,11 @@ void FindStringIndicesDispatch(Isolate* isolate, String* subject,
template <typename ResultSeqString>
MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
Isolate* isolate, Handle<String> subject, Handle<JSRegExp> pattern_regexp,
- Handle<String> replacement, Handle<JSObject> last_match_info) {
+ Handle<String> replacement, Handle<JSObject> last_match_info, Zone* zone) {
DCHECK(subject->IsFlat());
DCHECK(replacement->IsFlat());
- ZoneScope zone_scope(isolate->runtime_zone());
- ZoneList<int> indices(8, zone_scope.zone());
+ ZoneList<int> indices(8, zone);
DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
String* pattern =
String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
@@ -403,7 +402,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
int replacement_len = replacement->length();
FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff,
- zone_scope.zone());
+ zone);
int matches = indices.length();
if (matches == 0) return *subject;
@@ -483,10 +482,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
if (regexp->TypeTag() == JSRegExp::ATOM && simple_replace) {
if (subject->HasOnlyOneByteChars() && replacement->HasOnlyOneByteChars()) {
return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
- isolate, subject, regexp, replacement, last_match_info);
+ isolate, subject, regexp, replacement, last_match_info,
+ zone_scope.zone());
} else {
return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>(
- isolate, subject, regexp, replacement, last_match_info);
+ isolate, subject, regexp, replacement, last_match_info,
+ zone_scope.zone());
}
}
@@ -548,7 +549,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
template <typename ResultSeqString>
MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
Isolate* isolate, Handle<String> subject, Handle<JSRegExp> regexp,
- Handle<JSObject> last_match_info) {
+ Handle<JSObject> last_match_info, Zone* zone) {
DCHECK(subject->IsFlat());
// Shortcut for simple non-regexp global replacements
@@ -556,10 +557,10 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
Handle<String> empty_string = isolate->factory()->empty_string();
if (subject->IsOneByteRepresentation()) {
return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
- isolate, subject, regexp, empty_string, last_match_info);
+ isolate, subject, regexp, empty_string, last_match_info, zone);
} else {
return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>(
- isolate, subject, regexp, empty_string, last_match_info);
+ isolate, subject, regexp, empty_string, last_match_info, zone);
}
}
@@ -658,13 +659,15 @@ RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) {
subject = String::Flatten(subject);
+ ZoneScope zone_scope(isolate->runtime_zone());
+
if (replacement->length() == 0) {
if (subject->HasOnlyOneByteChars()) {
return StringReplaceGlobalRegExpWithEmptyString<SeqOneByteString>(
- isolate, subject, regexp, last_match_info);
+ isolate, subject, regexp, last_match_info, zone_scope.zone());
} else {
return StringReplaceGlobalRegExpWithEmptyString<SeqTwoByteString>(
- isolate, subject, regexp, last_match_info);
+ isolate, subject, regexp, last_match_info, zone_scope.zone());
}
}
« no previous file with comments | « src/list.h ('k') | src/zone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698