Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1257)

Unified Diff: src/runtime.cc

Issue 39184: Optimizing nested, constant object literals (like JSON objects) by building o... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 1431)
+++ src/runtime.cc (working copy)
@@ -99,9 +99,9 @@
static Handle<Map> ComputeObjectLiteralMap(
- Handle<Context> context,
- Handle<FixedArray> constant_properties,
- bool* is_result_from_cache) {
+ Handle<Context> context,
+ Handle<FixedArray> constant_properties,
+ bool* is_result_from_cache) {
int number_of_properties = constant_properties->length() / 2;
if (FLAG_canonicalize_object_literal_maps) {
// First find prefix of consecutive symbol keys.
@@ -131,14 +131,9 @@
}
-static Object* Runtime_CreateObjectLiteralBoilerplate(Arguments args) {
- HandleScope scope;
- ASSERT(args.length() == 3);
- // Copy the arguments.
- Handle<FixedArray> literals = args.at<FixedArray>(0);
- int literals_index = Smi::cast(args[1])->value();
- Handle<FixedArray> constant_properties = args.at<FixedArray>(2);
-
+static Handle<Object> CreateObjectLiteralBoilerplate(
+ Handle<FixedArray> literals,
+ Handle<FixedArray> constant_properties) {
// Get the global context from the literals array. This is the
// context in which the function was created and we use the object
// function from this context to create the object literal. We do
@@ -161,6 +156,12 @@
for (int index = 0; index < length; index +=2) {
Handle<Object> key(constant_properties->get(index+0));
Handle<Object> value(constant_properties->get(index+1));
+ if (value->IsFixedArray()) {
+ // The value contains the constant_properties of a
+ // simple object literal.
+ Handle<FixedArray> array = Handle<FixedArray>::cast(value);
+ value = CreateObjectLiteralBoilerplate(literals, array);
+ }
Handle<Object> result;
uint32_t element_index = 0;
if (key->IsSymbol()) {
@@ -185,14 +186,31 @@
// exception, the exception is converted to an empty handle in
// the handle based operations. In that case, we need to
// convert back to an exception.
- if (result.is_null()) return Failure::Exception();
+ if (result.is_null()) return result;
}
}
+ return boilerplate;
+}
+
+
+static Object* Runtime_CreateObjectLiteralBoilerplate(Arguments args) {
+ HandleScope scope;
+ ASSERT(args.length() == 3);
+ // Copy the arguments.
+ Handle<FixedArray> literals = args.at<FixedArray>(0);
+ int literals_index = Smi::cast(args[1])->value();
+ Handle<FixedArray> constant_properties = args.at<FixedArray>(2);
+
+ Handle<Object> result =
+ CreateObjectLiteralBoilerplate(literals, constant_properties);
+
+ if (result.is_null()) return Failure::Exception();
+
// Update the functions literal and return the boilerplate.
- literals->set(literals_index, *boilerplate);
+ literals->set(literals_index, *result);;
- return *boilerplate;
+ return *result;
}
« src/parser.cc ('K') | « src/parser.cc ('k') | test/mjsunit/object-literal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698