Bug 1368461 part 1 - Allow nursery allocation for RegExps allocated by CloneRegExpObject. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 30 May 2017 12:11:15 +0200
changeset 409381 5be34c2d1de5d169706e498f0cadbbaa80a4ad29
parent 409380 30df9022124c78335c22ba8c54b2073544f4e993
child 409382 5f12fd37c3bd5e511968b5b9a1c389a41119f66c
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1368461
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368461 part 1 - Allow nursery allocation for RegExps allocated by CloneRegExpObject. r=jonco
js/src/vm/RegExpObject.cpp
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -49,18 +49,20 @@ JS_STATIC_ASSERT(IgnoreCaseFlag == JSREG
 JS_STATIC_ASSERT(GlobalFlag == JSREG_GLOB);
 JS_STATIC_ASSERT(MultilineFlag == JSREG_MULTILINE);
 JS_STATIC_ASSERT(StickyFlag == JSREG_STICKY);
 JS_STATIC_ASSERT(UnicodeFlag == JSREG_UNICODE);
 
 RegExpObject*
 js::RegExpAlloc(JSContext* cx, HandleObject proto /* = nullptr */)
 {
-    // Note: RegExp objects are always allocated in the tenured heap. This is
-    // not strictly required, but simplifies embedding them in jitcode.
+    // Note: RegExp objects allocated here are always in the tenured heap. This
+    // is required for RegExp objects allocated by the parser and it also
+    // simplifies embedding them in jitcode. Cloned RegExp objects can be
+    // nursery-allocated though, see CloneRegExpObject.
     Rooted<RegExpObject*> regexp(cx);
 
     regexp = NewObjectWithClassProto<RegExpObject>(cx, proto, TenuredObject);
     if (!regexp)
         return nullptr;
 
     regexp->initPrivate(nullptr);
 
@@ -1337,20 +1339,19 @@ RegExpCompartment::sizeOfExcludingThis(m
 
 /* Functions */
 
 JSObject*
 js::CloneRegExpObject(JSContext* cx, JSObject* obj_)
 {
     Rooted<RegExpObject*> regex(cx, &obj_->as<RegExpObject>());
 
-    // Unlike RegExpAlloc, all clones must use |regex|'s group.  Allocate
-    // in the tenured heap to simplify embedding them in JIT code.
+    // Unlike RegExpAlloc, all clones must use |regex|'s group.
     RootedObjectGroup group(cx, regex->group());
-    Rooted<RegExpObject*> clone(cx, NewObjectWithGroup<RegExpObject>(cx, group, TenuredObject));
+    Rooted<RegExpObject*> clone(cx, NewObjectWithGroup<RegExpObject>(cx, group, GenericObject));
     if (!clone)
         return nullptr;
     clone->initPrivate(nullptr);
 
     if (!EmptyShape::ensureInitialCustomShape<RegExpObject>(cx, clone))
         return nullptr;
 
     Rooted<JSAtom*> source(cx, regex->getSource());