Revision: 5724
Author: [email protected]
Date: Thu Oct 28 01:43:47 2010
Log: Add gc() calls to some tests to please valgrind.
Review URL: http://codereview.chromium.org/4116005
http://code.google.com/p/v8/source/detail?r=5724
Modified:
/branches/bleeding_edge/src/execution.cc
/branches/bleeding_edge/test/mjsunit/string-externalize.js
/branches/bleeding_edge/test/mjsunit/string-replace-with-empty.js
=======================================
--- /branches/bleeding_edge/src/execution.cc Mon Oct 25 08:22:03 2010
+++ /branches/bleeding_edge/src/execution.cc Thu Oct 28 01:43:47 2010
@@ -797,6 +797,7 @@
if (result && !string->IsSymbol()) {
i::ExternalStringTable::AddString(*string);
}
+ if (!result) delete resource;
} else {
uc16* data = new uc16[string->length()];
String::WriteToFlat(*string, data, 0, string->length());
@@ -806,6 +807,7 @@
if (result && !string->IsSymbol()) {
i::ExternalStringTable::AddString(*string);
}
+ if (!result) delete resource;
}
if (!result) {
return v8::ThrowException(v8::String::New("externalizeString()
failed."));
=======================================
--- /branches/bleeding_edge/test/mjsunit/string-externalize.js Thu Jun 17
09:19:28 2010
+++ /branches/bleeding_edge/test/mjsunit/string-externalize.js Thu Oct 28
01:43:47 2010
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --expose-externalize-string
+// Flags: --expose-externalize-string --expose-gc
var size = 1024;
@@ -93,3 +93,7 @@
for (var i = 0; i < 10; i++) {
test();
}
+
+// Clean up string to make Valgrind happy.
+gc();
+gc();
=======================================
--- /branches/bleeding_edge/test/mjsunit/string-replace-with-empty.js Tue
Jul 6 05:22:19 2010
+++ /branches/bleeding_edge/test/mjsunit/string-replace-with-empty.js Thu
Oct 28 01:43:47 2010
@@ -25,33 +25,45 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --expose-externalize-string
-
-assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, ""));
-assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, ""));
-
-var expected = "0123";
-var cons = "a0b1c2d3";
-for (var i = 0; i < 5; i++) {
- expected += expected;
- cons += cons;
-}
-assertEquals(expected, cons.replace(/[a-z]/g, ""));
-cons = "\u12340b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
-}
-assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
-
-cons = "a0b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
-}
-externalizeString(cons, true/* force two-byte */);
-assertEquals(expected, cons.replace(/[a-z]/g, ""));
-cons = "\u12340b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
-}
-externalizeString(cons);
-assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
+// Flags: --expose-externalize-string --expose-gc
+
+function test() {
+ assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, ""));
+ assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, ""));
+
+ var expected = "0123";
+ var cons = "a0b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ expected += expected;
+ cons += cons;
+ }
+ assertEquals(expected, cons.replace(/[a-z]/g, ""));
+ cons = "\u12340b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
+
+ cons = "a0b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ externalizeString(cons, true/* force two-byte */);
+ assertEquals(expected, cons.replace(/[a-z]/g, ""));
+ cons = "\u12340b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ externalizeString(cons);
+ assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
+}
+
+test();
+
+// Clear the regexp cache to allow the GC to work.
+"foo".replace(/foo/g, "");
+
+// GC in order to free up things on the C side so we don't get
+// a memory leak. This makes valgrind happy.
+gc();
+gc();
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev