Commit a448c13c authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Add gc() calls to some tests to please valgrind.

Review URL: http://codereview.chromium.org/4116005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5724 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 21228278
...@@ -797,6 +797,7 @@ v8::Handle<v8::Value> ExternalizeStringExtension::Externalize( ...@@ -797,6 +797,7 @@ v8::Handle<v8::Value> ExternalizeStringExtension::Externalize(
if (result && !string->IsSymbol()) { if (result && !string->IsSymbol()) {
i::ExternalStringTable::AddString(*string); i::ExternalStringTable::AddString(*string);
} }
if (!result) delete resource;
} else { } else {
uc16* data = new uc16[string->length()]; uc16* data = new uc16[string->length()];
String::WriteToFlat(*string, data, 0, string->length()); String::WriteToFlat(*string, data, 0, string->length());
...@@ -806,6 +807,7 @@ v8::Handle<v8::Value> ExternalizeStringExtension::Externalize( ...@@ -806,6 +807,7 @@ v8::Handle<v8::Value> ExternalizeStringExtension::Externalize(
if (result && !string->IsSymbol()) { if (result && !string->IsSymbol()) {
i::ExternalStringTable::AddString(*string); i::ExternalStringTable::AddString(*string);
} }
if (!result) delete resource;
} }
if (!result) { if (!result) {
return v8::ThrowException(v8::String::New("externalizeString() failed.")); return v8::ThrowException(v8::String::New("externalizeString() failed."));
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // 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; var size = 1024;
...@@ -93,3 +93,7 @@ function test() { ...@@ -93,3 +93,7 @@ function test() {
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
test(); test();
} }
// Clean up string to make Valgrind happy.
gc();
gc();
...@@ -25,33 +25,45 @@ ...@@ -25,33 +25,45 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-externalize-string // Flags: --expose-externalize-string --expose-gc
assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, "")); function test() {
assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, "")); assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, ""));
assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, ""));
var expected = "0123"; var expected = "0123";
var cons = "a0b1c2d3"; var cons = "a0b1c2d3";
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
expected += expected; expected += expected;
cons += cons; cons += cons;
} }
assertEquals(expected, cons.replace(/[a-z]/g, "")); assertEquals(expected, cons.replace(/[a-z]/g, ""));
cons = "\u12340b1c2d3"; cons = "\u12340b1c2d3";
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
cons += cons; cons += cons;
} }
assertEquals(expected, cons.replace(/[\u1234a-z]/g, "")); assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
cons = "a0b1c2d3"; cons = "a0b1c2d3";
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
cons += cons; cons += cons;
} }
externalizeString(cons, true/* force two-byte */); externalizeString(cons, true/* force two-byte */);
assertEquals(expected, cons.replace(/[a-z]/g, "")); assertEquals(expected, cons.replace(/[a-z]/g, ""));
cons = "\u12340b1c2d3"; cons = "\u12340b1c2d3";
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
cons += cons; cons += cons;
}
externalizeString(cons);
assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
} }
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();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment