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

Side by Side Diff: src/hydrogen.cc

Issue 8640001: Implement crankshaft support for nested object literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported lithium part to x64 and ARM. Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3298 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 HValue* context = environment()->LookupContext(); 3309 HValue* context = environment()->LookupContext();
3310 3310
3311 HRegExpLiteral* instr = new(zone()) HRegExpLiteral(context, 3311 HRegExpLiteral* instr = new(zone()) HRegExpLiteral(context,
3312 expr->pattern(), 3312 expr->pattern(),
3313 expr->flags(), 3313 expr->flags(),
3314 expr->literal_index()); 3314 expr->literal_index());
3315 return ast_context()->ReturnInstruction(instr, expr->id()); 3315 return ast_context()->ReturnInstruction(instr, expr->id());
3316 } 3316 }
3317 3317
3318 3318
3319 // Determines whether the given object literal boilerplate satisfies all
3320 // limits to be considered for fast deep-copying and computes the total
3321 // size of all objects that are part of the graph.
3322 static bool IsFastObjectLiteral(Handle<JSObject> boilerplate,
3323 int max_depth,
3324 int* max_properties,
3325 int* total_size) {
3326 if (max_depth <= 0) return false;
3327
3328 FixedArrayBase* elements = boilerplate->elements();
3329 if (elements->length() > 0 &&
3330 elements->map() != HEAP->fixed_cow_array_map()) {
3331 return false;
3332 }
3333
3334 FixedArray* properties = boilerplate->properties();
3335 if (properties->length() > 0) {
3336 return false;
3337 } else {
3338 int nof = boilerplate->map()->inobject_properties();
3339 for (int i = 0; i < nof; i++) {
3340 if ((*max_properties)-- <= 0) return false;
3341 Handle<Object> value(boilerplate->InObjectPropertyAt(i));
3342 if (value->IsJSObject()) {
3343 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
3344 if (!IsFastObjectLiteral(value_object,
3345 max_depth - 1,
3346 max_properties,
3347 total_size)) {
3348 return false;
3349 }
3350 }
3351 }
3352 }
3353
3354 *total_size += boilerplate->map()->instance_size();
3355 return true;
3356 }
3357
3358
3319 void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { 3359 void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
3320 ASSERT(!HasStackOverflow()); 3360 ASSERT(!HasStackOverflow());
3321 ASSERT(current_block() != NULL); 3361 ASSERT(current_block() != NULL);
3322 ASSERT(current_block()->HasPredecessor()); 3362 ASSERT(current_block()->HasPredecessor());
3363 Handle<JSFunction> closure = function_state()->compilation_info()->closure();
3323 HValue* context = environment()->LookupContext(); 3364 HValue* context = environment()->LookupContext();
3324 HObjectLiteral* literal = 3365 HInstruction* literal;
3325 new(zone()) HObjectLiteral(context, 3366
3326 expr->constant_properties(), 3367 // Check whether to use fast or slow deep-copying for boilerplate.
3327 expr->fast_elements(), 3368 int total_size = 0;
3328 expr->literal_index(), 3369 int max_properties = HObjectLiteralFast::kMaxObjectLiteralProperties;
3329 expr->depth(), 3370 Handle<Object> boilerplate(closure->literals()->get(expr->literal_index()));
3330 expr->has_function()); 3371 if (boilerplate->IsJSObject() &&
3372 IsFastObjectLiteral(Handle<JSObject>::cast(boilerplate),
3373 HObjectLiteralFast::kMaxObjectLiteralDepth,
3374 &max_properties,
3375 &total_size)) {
3376 Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate);
3377 literal = new(zone()) HObjectLiteralFast(context,
3378 boilerplate_object,
3379 total_size,
3380 expr->literal_index(),
3381 expr->depth());
3382 } else {
3383 literal = new(zone()) HObjectLiteralGeneric(context,
3384 expr->constant_properties(),
3385 expr->fast_elements(),
3386 expr->literal_index(),
3387 expr->depth(),
3388 expr->has_function());
3389 }
3390
3331 // The object is expected in the bailout environment during computation 3391 // The object is expected in the bailout environment during computation
3332 // of the property values and is the value of the entire expression. 3392 // of the property values and is the value of the entire expression.
3333 PushAndAdd(literal); 3393 PushAndAdd(literal);
3334 3394
3335 expr->CalculateEmitStore(); 3395 expr->CalculateEmitStore();
3336 3396
3337 for (int i = 0; i < expr->properties()->length(); i++) { 3397 for (int i = 0; i < expr->properties()->length(); i++) {
3338 ObjectLiteral::Property* property = expr->properties()->at(i); 3398 ObjectLiteral::Property* property = expr->properties()->at(i);
3339 if (property->IsCompileTimeValue()) continue; 3399 if (property->IsCompileTimeValue()) continue;
3340 3400
(...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after
7152 } 7212 }
7153 } 7213 }
7154 7214
7155 #ifdef DEBUG 7215 #ifdef DEBUG
7156 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7216 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7157 if (allocator_ != NULL) allocator_->Verify(); 7217 if (allocator_ != NULL) allocator_->Verify();
7158 #endif 7218 #endif
7159 } 7219 }
7160 7220
7161 } } // namespace v8::internal 7221 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698