OLD | NEW |
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 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3329 | 3329 |
3330 // Determines whether the given object literal boilerplate satisfies all | 3330 // Determines whether the given object literal boilerplate satisfies all |
3331 // limits to be considered for fast deep-copying and computes the total | 3331 // limits to be considered for fast deep-copying and computes the total |
3332 // size of all objects that are part of the graph. | 3332 // size of all objects that are part of the graph. |
3333 static bool IsFastObjectLiteral(Handle<JSObject> boilerplate, | 3333 static bool IsFastObjectLiteral(Handle<JSObject> boilerplate, |
3334 int max_depth, | 3334 int max_depth, |
3335 int* max_properties, | 3335 int* max_properties, |
3336 int* total_size) { | 3336 int* total_size) { |
3337 if (max_depth <= 0) return false; | 3337 if (max_depth <= 0) return false; |
3338 | 3338 |
3339 FixedArrayBase* elements = boilerplate->elements(); | 3339 Handle<FixedArrayBase> elements(boilerplate->elements()); |
3340 if (elements->length() > 0 && | 3340 if (elements->length() > 0 && |
3341 elements->map() != HEAP->fixed_cow_array_map()) { | 3341 elements->map() != HEAP->fixed_cow_array_map()) { |
3342 return false; | 3342 return false; |
3343 } | 3343 } |
3344 | 3344 |
3345 FixedArray* properties = boilerplate->properties(); | 3345 Handle<FixedArray> properties(boilerplate->properties()); |
3346 if (properties->length() > 0) { | 3346 if (properties->length() > 0) { |
3347 return false; | 3347 return false; |
3348 } else { | 3348 } else { |
3349 int nof = boilerplate->map()->inobject_properties(); | 3349 int nof = boilerplate->map()->inobject_properties(); |
3350 for (int i = 0; i < nof; i++) { | 3350 for (int i = 0; i < nof; i++) { |
3351 if ((*max_properties)-- <= 0) return false; | 3351 if ((*max_properties)-- <= 0) return false; |
3352 Handle<Object> value(boilerplate->InObjectPropertyAt(i)); | 3352 Handle<Object> value(boilerplate->InObjectPropertyAt(i)); |
3353 if (value->IsJSObject()) { | 3353 if (value->IsJSObject()) { |
3354 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 3354 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
3355 if (!IsFastObjectLiteral(value_object, | 3355 if (!IsFastObjectLiteral(value_object, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3461 | 3461 |
3462 | 3462 |
3463 void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 3463 void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
3464 ASSERT(!HasStackOverflow()); | 3464 ASSERT(!HasStackOverflow()); |
3465 ASSERT(current_block() != NULL); | 3465 ASSERT(current_block() != NULL); |
3466 ASSERT(current_block()->HasPredecessor()); | 3466 ASSERT(current_block()->HasPredecessor()); |
3467 ZoneList<Expression*>* subexprs = expr->values(); | 3467 ZoneList<Expression*>* subexprs = expr->values(); |
3468 int length = subexprs->length(); | 3468 int length = subexprs->length(); |
3469 HValue* context = environment()->LookupContext(); | 3469 HValue* context = environment()->LookupContext(); |
3470 | 3470 |
3471 FixedArray* literals = environment()->closure()->literals(); | 3471 Handle<FixedArray> literals(environment()->closure()->literals()); |
3472 Handle<Object> raw_boilerplate(literals->get(expr->literal_index())); | 3472 Handle<Object> raw_boilerplate(literals->get(expr->literal_index())); |
3473 | 3473 |
3474 // For now, no boilerplate causes a deopt. | 3474 // For now, no boilerplate causes a deopt. |
3475 if (raw_boilerplate->IsUndefined()) { | 3475 if (raw_boilerplate->IsUndefined()) { |
3476 AddInstruction(new(zone()) HSoftDeoptimize); | 3476 AddInstruction(new(zone()) HSoftDeoptimize); |
3477 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); | 3477 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
3478 } | 3478 } |
3479 | 3479 |
3480 Handle<JSObject> boilerplate(Handle<JSObject>::cast(raw_boilerplate)); | 3480 Handle<JSObject> boilerplate(Handle<JSObject>::cast(raw_boilerplate)); |
3481 ElementsKind boilerplate_elements_kind = boilerplate->GetElementsKind(); | 3481 ElementsKind boilerplate_elements_kind = boilerplate->GetElementsKind(); |
(...skipping 3766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7248 } | 7248 } |
7249 } | 7249 } |
7250 | 7250 |
7251 #ifdef DEBUG | 7251 #ifdef DEBUG |
7252 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7252 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
7253 if (allocator_ != NULL) allocator_->Verify(); | 7253 if (allocator_ != NULL) allocator_->Verify(); |
7254 #endif | 7254 #endif |
7255 } | 7255 } |
7256 | 7256 |
7257 } } // namespace v8::internal | 7257 } } // namespace v8::internal |
OLD | NEW |