Commit a79d6227 authored by verwaest@chromium.org's avatar verwaest@chromium.org

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
parent 2541f250
...@@ -291,6 +291,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() { ...@@ -291,6 +291,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
// Parse a JSON object. Position must be right at '{'. // Parse a JSON object. Position must be right at '{'.
template <bool seq_ascii> template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
HandleScope scope(isolate());
Handle<JSObject> json_object = Handle<JSObject> json_object =
factory()->NewJSObject(object_constructor(), pretenure_); factory()->NewJSObject(object_constructor(), pretenure_);
ASSERT_EQ(c0_, '{'); ASSERT_EQ(c0_, '{');
...@@ -358,12 +359,13 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { ...@@ -358,12 +359,13 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
} }
} }
AdvanceSkipWhitespace(); AdvanceSkipWhitespace();
return json_object; return scope.CloseAndEscape(json_object);
} }
// Parse a JSON array. Position must be right at '['. // Parse a JSON array. Position must be right at '['.
template <bool seq_ascii> template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
HandleScope scope(isolate());
ZoneScope zone_scope(zone(), DELETE_ON_EXIT); ZoneScope zone_scope(zone(), DELETE_ON_EXIT);
ZoneList<Handle<Object> > elements(4, zone()); ZoneList<Handle<Object> > elements(4, zone());
ASSERT_EQ(c0_, '['); ASSERT_EQ(c0_, '[');
...@@ -386,8 +388,9 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { ...@@ -386,8 +388,9 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
for (int i = 0, n = elements.length(); i < n; i++) { for (int i = 0, n = elements.length(); i < n; i++) {
fast_elements->set(i, *elements[i]); fast_elements->set(i, *elements[i]);
} }
return factory()->NewJSArrayWithElements( Handle<Object> json_array = factory()->NewJSArrayWithElements(
fast_elements, FAST_ELEMENTS, pretenure_); fast_elements, FAST_ELEMENTS, pretenure_);
return scope.CloseAndEscape(json_array);
} }
......
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