From a79d622720c3fb6d4e155a96658461d8ead0de1e Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 25 Mar 2013 17:10:33 +0000 Subject: [PATCH] Create a new HandleScope for each JSON-parsed object to avoid excessive growth Review URL: https://chromiumcodereview.appspot.com/12880019 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14069 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/json-parser.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/json-parser.h b/src/json-parser.h index 28ef8b33c8..f50c352e7e 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -291,6 +291,7 @@ Handle JsonParser::ParseJsonValue() { // Parse a JSON object. Position must be right at '{'. template Handle JsonParser::ParseJsonObject() { + HandleScope scope(isolate()); Handle json_object = factory()->NewJSObject(object_constructor(), pretenure_); ASSERT_EQ(c0_, '{'); @@ -358,12 +359,13 @@ Handle JsonParser::ParseJsonObject() { } } AdvanceSkipWhitespace(); - return json_object; + return scope.CloseAndEscape(json_object); } // Parse a JSON array. Position must be right at '['. template Handle JsonParser::ParseJsonArray() { + HandleScope scope(isolate()); ZoneScope zone_scope(zone(), DELETE_ON_EXIT); ZoneList > elements(4, zone()); ASSERT_EQ(c0_, '['); @@ -386,8 +388,9 @@ Handle JsonParser::ParseJsonArray() { for (int i = 0, n = elements.length(); i < n; i++) { fast_elements->set(i, *elements[i]); } - return factory()->NewJSArrayWithElements( + Handle json_array = factory()->NewJSArrayWithElements( fast_elements, FAST_ELEMENTS, pretenure_); + return scope.CloseAndEscape(json_array); }