OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 if (!pre_fill_with_holes && length != capacity) { | 1569 if (!pre_fill_with_holes && length != capacity) { |
1570 // Fill unused capacity with the hole. | 1570 // Fill unused capacity with the hole. |
1571 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1571 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
1572 key, capacity); | 1572 key, capacity); |
1573 } | 1573 } |
1574 } | 1574 } |
1575 | 1575 |
1576 | 1576 |
1577 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, | 1577 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
1578 HValue* boilerplate, | 1578 HValue* boilerplate, |
| 1579 HValue* allocation_site, |
1579 AllocationSiteMode mode, | 1580 AllocationSiteMode mode, |
1580 ElementsKind kind, | 1581 ElementsKind kind, |
1581 int length) { | 1582 int length) { |
1582 NoObservableSideEffectsScope no_effects(this); | 1583 NoObservableSideEffectsScope no_effects(this); |
1583 | 1584 |
1584 // All sizes here are multiples of kPointerSize. | 1585 // All sizes here are multiples of kPointerSize. |
1585 int size = JSArray::kSize; | 1586 int size = JSArray::kSize; |
1586 if (mode == TRACK_ALLOCATION_SITE) { | 1587 if (mode == TRACK_ALLOCATION_SITE) { |
1587 size += AllocationSiteInfo::kSize; | 1588 size += AllocationSiteInfo::kSize; |
1588 } | 1589 } |
(...skipping 16 matching lines...) Expand all Loading... |
1605 // Copy the JS array part. | 1606 // Copy the JS array part. |
1606 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 1607 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
1607 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 1608 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
1608 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 1609 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
1609 AddStore(object, access, AddLoad(boilerplate, access)); | 1610 AddStore(object, access, AddLoad(boilerplate, access)); |
1610 } | 1611 } |
1611 } | 1612 } |
1612 | 1613 |
1613 // Create an allocation site info if requested. | 1614 // Create an allocation site info if requested. |
1614 if (mode == TRACK_ALLOCATION_SITE) { | 1615 if (mode == TRACK_ALLOCATION_SITE) { |
1615 BuildCreateAllocationSiteInfo(object, JSArray::kSize, boilerplate); | 1616 BuildCreateAllocationSiteInfo(object, JSArray::kSize, allocation_site); |
1616 } | 1617 } |
1617 | 1618 |
1618 if (length > 0) { | 1619 if (length > 0) { |
1619 // Get hold of the elements array of the boilerplate and setup the | 1620 // Get hold of the elements array of the boilerplate and setup the |
1620 // elements pointer in the resulting object. | 1621 // elements pointer in the resulting object. |
1621 HValue* boilerplate_elements = AddLoadElements(boilerplate); | 1622 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
1622 HValue* object_elements = Add<HInnerAllocatedObject>(object, elems_offset); | 1623 HValue* object_elements = Add<HInnerAllocatedObject>(object, elems_offset); |
1623 AddStore(object, HObjectAccess::ForElementsPointer(), object_elements); | 1624 AddStore(object, HObjectAccess::ForElementsPointer(), object_elements); |
1624 | 1625 |
1625 // Copy the elements array header. | 1626 // Copy the elements array header. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 if_nil.Deopt(); | 1680 if_nil.Deopt(); |
1680 } | 1681 } |
1681 } | 1682 } |
1682 | 1683 |
1683 if_nil.CaptureContinuation(continuation); | 1684 if_nil.CaptureContinuation(continuation); |
1684 } | 1685 } |
1685 | 1686 |
1686 | 1687 |
1687 HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, | 1688 HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, |
1688 int previous_object_size, | 1689 int previous_object_size, |
1689 HValue* payload) { | 1690 HValue* alloc_site) { |
1690 HInnerAllocatedObject* alloc_site = Add<HInnerAllocatedObject>( | 1691 ASSERT(alloc_site != NULL); |
| 1692 HInnerAllocatedObject* alloc_site_info = Add<HInnerAllocatedObject>( |
1691 previous_object, previous_object_size); | 1693 previous_object, previous_object_size); |
1692 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map()); | 1694 Handle<Map> alloc_site_info_map( |
1693 AddStoreMapConstant(alloc_site, alloc_site_map); | 1695 isolate()->heap()->allocation_site_info_map()); |
1694 HObjectAccess access = HObjectAccess::ForAllocationSitePayload(); | 1696 AddStoreMapConstant(alloc_site_info, alloc_site_info_map); |
1695 AddStore(alloc_site, access, payload); | 1697 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); |
1696 return alloc_site; | 1698 AddStore(alloc_site_info, access, alloc_site); |
| 1699 return alloc_site_info; |
1697 } | 1700 } |
1698 | 1701 |
1699 | 1702 |
1700 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { | 1703 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { |
1701 // Get the global context, then the native context | 1704 // Get the global context, then the native context |
1702 HInstruction* global_object = Add<HGlobalObject>(context); | 1705 HInstruction* global_object = Add<HGlobalObject>(context); |
1703 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 1706 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
1704 GlobalObject::kNativeContextOffset); | 1707 GlobalObject::kNativeContextOffset); |
1705 return AddLoad(global_object, access); | 1708 return AddLoad(global_object, access); |
1706 } | 1709 } |
(...skipping 12 matching lines...) Expand all Loading... |
1719 ElementsKind kind, | 1722 ElementsKind kind, |
1720 HValue* allocation_site_payload, | 1723 HValue* allocation_site_payload, |
1721 HValue* constructor_function, | 1724 HValue* constructor_function, |
1722 AllocationSiteOverrideMode override_mode) : | 1725 AllocationSiteOverrideMode override_mode) : |
1723 builder_(builder), | 1726 builder_(builder), |
1724 kind_(kind), | 1727 kind_(kind), |
1725 allocation_site_payload_(allocation_site_payload), | 1728 allocation_site_payload_(allocation_site_payload), |
1726 constructor_function_(constructor_function) { | 1729 constructor_function_(constructor_function) { |
1727 mode_ = override_mode == DISABLE_ALLOCATION_SITES | 1730 mode_ = override_mode == DISABLE_ALLOCATION_SITES |
1728 ? DONT_TRACK_ALLOCATION_SITE | 1731 ? DONT_TRACK_ALLOCATION_SITE |
1729 : AllocationSiteInfo::GetMode(kind); | 1732 : AllocationSite::GetMode(kind); |
1730 } | 1733 } |
1731 | 1734 |
1732 | 1735 |
1733 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1736 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1734 ElementsKind kind, | 1737 ElementsKind kind, |
1735 HValue* constructor_function) : | 1738 HValue* constructor_function) : |
1736 builder_(builder), | 1739 builder_(builder), |
1737 kind_(kind), | 1740 kind_(kind), |
1738 mode_(DONT_TRACK_ALLOCATION_SITE), | 1741 mode_(DONT_TRACK_ALLOCATION_SITE), |
1739 allocation_site_payload_(NULL), | 1742 allocation_site_payload_(NULL), |
(...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5426 &data_size, | 5429 &data_size, |
5427 &pointer_size)) { | 5430 &pointer_size)) { |
5428 Handle<JSObject> original_boilerplate_object = | 5431 Handle<JSObject> original_boilerplate_object = |
5429 Handle<JSObject>::cast(original_boilerplate); | 5432 Handle<JSObject>::cast(original_boilerplate); |
5430 Handle<JSObject> boilerplate_object = | 5433 Handle<JSObject> boilerplate_object = |
5431 DeepCopy(original_boilerplate_object); | 5434 DeepCopy(original_boilerplate_object); |
5432 | 5435 |
5433 literal = BuildFastLiteral(context, | 5436 literal = BuildFastLiteral(context, |
5434 boilerplate_object, | 5437 boilerplate_object, |
5435 original_boilerplate_object, | 5438 original_boilerplate_object, |
| 5439 Handle<Object>::null(), |
5436 data_size, | 5440 data_size, |
5437 pointer_size, | 5441 pointer_size, |
5438 DONT_TRACK_ALLOCATION_SITE); | 5442 DONT_TRACK_ALLOCATION_SITE); |
5439 } else { | 5443 } else { |
5440 NoObservableSideEffectsScope no_effects(this); | 5444 NoObservableSideEffectsScope no_effects(this); |
5441 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5445 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
5442 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5446 Handle<FixedArray> constant_properties = expr->constant_properties(); |
5443 int literal_index = expr->literal_index(); | 5447 int literal_index = expr->literal_index(); |
5444 int flags = expr->fast_elements() | 5448 int flags = expr->fast_elements() |
5445 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; | 5449 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5533 | 5537 |
5534 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 5538 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
5535 ASSERT(!HasStackOverflow()); | 5539 ASSERT(!HasStackOverflow()); |
5536 ASSERT(current_block() != NULL); | 5540 ASSERT(current_block() != NULL); |
5537 ASSERT(current_block()->HasPredecessor()); | 5541 ASSERT(current_block()->HasPredecessor()); |
5538 ZoneList<Expression*>* subexprs = expr->values(); | 5542 ZoneList<Expression*>* subexprs = expr->values(); |
5539 int length = subexprs->length(); | 5543 int length = subexprs->length(); |
5540 HValue* context = environment()->LookupContext(); | 5544 HValue* context = environment()->LookupContext(); |
5541 HInstruction* literal; | 5545 HInstruction* literal; |
5542 | 5546 |
| 5547 Handle<AllocationSite> site; |
5543 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); | 5548 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); |
5544 Handle<Object> raw_boilerplate(literals->get(expr->literal_index()), | 5549 Handle<Object> literals_cell(literals->get(expr->literal_index()), |
5545 isolate()); | 5550 isolate()); |
5546 | 5551 Handle<Object> raw_boilerplate; |
5547 if (raw_boilerplate->IsUndefined()) { | 5552 if (literals_cell->IsUndefined()) { |
5548 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( | 5553 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( |
5549 isolate(), literals, expr->constant_elements()); | 5554 isolate(), literals, expr->constant_elements()); |
5550 if (raw_boilerplate.is_null()) { | 5555 if (raw_boilerplate.is_null()) { |
5551 return Bailout("array boilerplate creation failed"); | 5556 return Bailout("array boilerplate creation failed"); |
5552 } | 5557 } |
5553 literals->set(expr->literal_index(), *raw_boilerplate); | 5558 |
| 5559 site = isolate()->factory()->NewAllocationSite(); |
| 5560 site->set_payload(*raw_boilerplate); |
| 5561 literals->set(expr->literal_index(), *site); |
| 5562 |
5554 if (JSObject::cast(*raw_boilerplate)->elements()->map() == | 5563 if (JSObject::cast(*raw_boilerplate)->elements()->map() == |
5555 isolate()->heap()->fixed_cow_array_map()) { | 5564 isolate()->heap()->fixed_cow_array_map()) { |
5556 isolate()->counters()->cow_arrays_created_runtime()->Increment(); | 5565 isolate()->counters()->cow_arrays_created_runtime()->Increment(); |
5557 } | 5566 } |
| 5567 } else { |
| 5568 ASSERT(literals_cell->IsAllocationSite()); |
| 5569 site = Handle<AllocationSite>::cast(literals_cell); |
| 5570 raw_boilerplate = Handle<Object>(site->payload(), isolate()); |
5558 } | 5571 } |
5559 | 5572 |
| 5573 ASSERT(!raw_boilerplate.is_null()); |
| 5574 ASSERT(site->IsLiteralSite()); |
| 5575 |
5560 Handle<JSObject> original_boilerplate_object = | 5576 Handle<JSObject> original_boilerplate_object = |
5561 Handle<JSObject>::cast(raw_boilerplate); | 5577 Handle<JSObject>::cast(raw_boilerplate); |
5562 ElementsKind boilerplate_elements_kind = | 5578 ElementsKind boilerplate_elements_kind = |
5563 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); | 5579 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); |
5564 | 5580 |
5565 // TODO(mvstanton): This heuristic is only a temporary solution. In the | 5581 // TODO(mvstanton): This heuristic is only a temporary solution. In the |
5566 // end, we want to quit creating allocation site info after a certain number | 5582 // end, we want to quit creating allocation site info after a certain number |
5567 // of GCs for a call site. | 5583 // of GCs for a call site. |
5568 AllocationSiteMode mode = AllocationSiteInfo::GetMode( | 5584 AllocationSiteMode mode = AllocationSite::GetMode( |
5569 boilerplate_elements_kind); | 5585 boilerplate_elements_kind); |
5570 | 5586 |
5571 // Check whether to use fast or slow deep-copying for boilerplate. | 5587 // Check whether to use fast or slow deep-copying for boilerplate. |
5572 int data_size = 0; | 5588 int data_size = 0; |
5573 int pointer_size = 0; | 5589 int pointer_size = 0; |
5574 int max_properties = kMaxFastLiteralProperties; | 5590 int max_properties = kMaxFastLiteralProperties; |
5575 if (IsFastLiteral(original_boilerplate_object, | 5591 if (IsFastLiteral(original_boilerplate_object, |
5576 kMaxFastLiteralDepth, | 5592 kMaxFastLiteralDepth, |
5577 &max_properties, | 5593 &max_properties, |
5578 &data_size, | 5594 &data_size, |
5579 &pointer_size)) { | 5595 &pointer_size)) { |
5580 if (mode == TRACK_ALLOCATION_SITE) { | 5596 if (mode == TRACK_ALLOCATION_SITE) { |
5581 pointer_size += AllocationSiteInfo::kSize; | 5597 pointer_size += AllocationSiteInfo::kSize; |
5582 } | 5598 } |
5583 | 5599 |
5584 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); | 5600 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); |
5585 literal = BuildFastLiteral(context, | 5601 literal = BuildFastLiteral(context, |
5586 boilerplate_object, | 5602 boilerplate_object, |
5587 original_boilerplate_object, | 5603 original_boilerplate_object, |
| 5604 site, |
5588 data_size, | 5605 data_size, |
5589 pointer_size, | 5606 pointer_size, |
5590 mode); | 5607 mode); |
5591 } else { | 5608 } else { |
5592 NoObservableSideEffectsScope no_effects(this); | 5609 NoObservableSideEffectsScope no_effects(this); |
5593 // Boilerplate already exists and constant elements are never accessed, | 5610 // Boilerplate already exists and constant elements are never accessed, |
5594 // pass an empty fixed array to the runtime function instead. | 5611 // pass an empty fixed array to the runtime function instead. |
5595 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 5612 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
5596 int literal_index = expr->literal_index(); | 5613 int literal_index = expr->literal_index(); |
5597 | 5614 |
(...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9414 } else { | 9431 } else { |
9415 return new(zone()) HThisFunction; | 9432 return new(zone()) HThisFunction; |
9416 } | 9433 } |
9417 } | 9434 } |
9418 | 9435 |
9419 | 9436 |
9420 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( | 9437 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
9421 HValue* context, | 9438 HValue* context, |
9422 Handle<JSObject> boilerplate_object, | 9439 Handle<JSObject> boilerplate_object, |
9423 Handle<JSObject> original_boilerplate_object, | 9440 Handle<JSObject> original_boilerplate_object, |
| 9441 Handle<Object> allocation_site, |
9424 int data_size, | 9442 int data_size, |
9425 int pointer_size, | 9443 int pointer_size, |
9426 AllocationSiteMode mode) { | 9444 AllocationSiteMode mode) { |
9427 NoObservableSideEffectsScope no_effects(this); | 9445 NoObservableSideEffectsScope no_effects(this); |
9428 | 9446 |
9429 HInstruction* target = NULL; | 9447 HInstruction* target = NULL; |
9430 HInstruction* data_target = NULL; | 9448 HInstruction* data_target = NULL; |
9431 | 9449 |
9432 HAllocate::Flags flags = HAllocate::DefaultFlags(); | 9450 HAllocate::Flags flags = HAllocate::DefaultFlags(); |
9433 | 9451 |
(...skipping 17 matching lines...) Expand all Loading... |
9451 HValue* size_in_bytes = Add<HConstant>(pointer_size); | 9469 HValue* size_in_bytes = Add<HConstant>(pointer_size); |
9452 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); | 9470 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); |
9453 } | 9471 } |
9454 } else { | 9472 } else { |
9455 HValue* size_in_bytes = Add<HConstant>(data_size + pointer_size); | 9473 HValue* size_in_bytes = Add<HConstant>(data_size + pointer_size); |
9456 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); | 9474 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); |
9457 } | 9475 } |
9458 | 9476 |
9459 int offset = 0; | 9477 int offset = 0; |
9460 int data_offset = 0; | 9478 int data_offset = 0; |
9461 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, target, | 9479 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, |
9462 &offset, data_target, &data_offset, mode); | 9480 allocation_site, target, &offset, data_target, |
| 9481 &data_offset, mode); |
9463 return target; | 9482 return target; |
9464 } | 9483 } |
9465 | 9484 |
9466 | 9485 |
9467 void HOptimizedGraphBuilder::BuildEmitDeepCopy( | 9486 void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
9468 Handle<JSObject> boilerplate_object, | 9487 Handle<JSObject> boilerplate_object, |
9469 Handle<JSObject> original_boilerplate_object, | 9488 Handle<JSObject> original_boilerplate_object, |
| 9489 Handle<Object> allocation_site_object, |
9470 HInstruction* target, | 9490 HInstruction* target, |
9471 int* offset, | 9491 int* offset, |
9472 HInstruction* data_target, | 9492 HInstruction* data_target, |
9473 int* data_offset, | 9493 int* data_offset, |
9474 AllocationSiteMode mode) { | 9494 AllocationSiteMode mode) { |
| 9495 Zone* zone = this->zone(); |
| 9496 |
| 9497 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && |
| 9498 boilerplate_object->map()->CanTrackAllocationSite(); |
| 9499 |
| 9500 // If using allocation sites, then the payload on the site should already |
| 9501 // be filled in as a valid (boilerplate) array. |
| 9502 ASSERT(!create_allocation_site_info || |
| 9503 AllocationSite::cast(*allocation_site_object)->IsLiteralSite()); |
| 9504 |
| 9505 HInstruction* allocation_site = NULL; |
| 9506 |
| 9507 if (create_allocation_site_info) { |
| 9508 allocation_site = AddInstruction(new(zone) HConstant( |
| 9509 allocation_site_object, Representation::Tagged())); |
| 9510 } |
| 9511 |
| 9512 // Only elements backing stores for non-COW arrays need to be copied. |
9475 Handle<FixedArrayBase> elements(boilerplate_object->elements()); | 9513 Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
9476 Handle<FixedArrayBase> original_elements( | 9514 Handle<FixedArrayBase> original_elements( |
9477 original_boilerplate_object->elements()); | 9515 original_boilerplate_object->elements()); |
9478 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 9516 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
9479 | 9517 |
9480 int object_offset = *offset; | 9518 int object_offset = *offset; |
9481 int object_size = boilerplate_object->map()->instance_size(); | 9519 int object_size = boilerplate_object->map()->instance_size(); |
9482 int elements_size = (elements->length() > 0 && | 9520 int elements_size = (elements->length() > 0 && |
9483 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? | 9521 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? |
9484 elements->Size() : 0; | 9522 elements->Size() : 0; |
(...skipping 25 matching lines...) Expand all Loading... |
9510 Add<HInnerAllocatedObject>(target, object_offset); | 9548 Add<HInnerAllocatedObject>(target, object_offset); |
9511 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, | 9549 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, |
9512 object_properties, target, offset, data_target, data_offset); | 9550 object_properties, target, offset, data_target, data_offset); |
9513 } | 9551 } |
9514 | 9552 |
9515 // Create allocation site info. | 9553 // Create allocation site info. |
9516 if (mode == TRACK_ALLOCATION_SITE && | 9554 if (mode == TRACK_ALLOCATION_SITE && |
9517 boilerplate_object->map()->CanTrackAllocationSite()) { | 9555 boilerplate_object->map()->CanTrackAllocationSite()) { |
9518 elements_offset += AllocationSiteInfo::kSize; | 9556 elements_offset += AllocationSiteInfo::kSize; |
9519 *offset += AllocationSiteInfo::kSize; | 9557 *offset += AllocationSiteInfo::kSize; |
9520 HInstruction* original_boilerplate = | 9558 BuildCreateAllocationSiteInfo(target, JSArray::kSize, allocation_site); |
9521 Add<HConstant>(original_boilerplate_object); | |
9522 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); | |
9523 } | 9559 } |
9524 } | 9560 } |
9525 | 9561 |
9526 | 9562 |
9527 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( | 9563 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( |
9528 Handle<JSObject> boilerplate_object, | 9564 Handle<JSObject> boilerplate_object, |
9529 HInstruction* target, | 9565 HInstruction* target, |
9530 HInstruction* data_target, | 9566 HInstruction* data_target, |
9531 int object_offset, | 9567 int object_offset, |
9532 int elements_offset, | 9568 int elements_offset, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9610 | 9646 |
9611 if (value->IsJSObject()) { | 9647 if (value->IsJSObject()) { |
9612 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9648 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
9613 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 9649 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
9614 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), | 9650 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), |
9615 isolate())); | 9651 isolate())); |
9616 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, | 9652 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, |
9617 *offset); | 9653 *offset); |
9618 | 9654 |
9619 AddStore(object_properties, access, value_instruction); | 9655 AddStore(object_properties, access, value_instruction); |
9620 | 9656 BuildEmitDeepCopy(value_object, original_value_object, |
9621 BuildEmitDeepCopy(value_object, original_value_object, target, | 9657 Handle<Object>::null(), target, |
9622 offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); | 9658 offset, data_target, data_offset, |
| 9659 DONT_TRACK_ALLOCATION_SITE); |
9623 } else { | 9660 } else { |
9624 Representation representation = details.representation(); | 9661 Representation representation = details.representation(); |
9625 HInstruction* value_instruction = Add<HConstant>(value); | 9662 HInstruction* value_instruction = Add<HConstant>(value); |
9626 | 9663 |
9627 if (representation.IsDouble()) { | 9664 if (representation.IsDouble()) { |
9628 // Allocate a HeapNumber box and store the value into it. | 9665 // Allocate a HeapNumber box and store the value into it. |
9629 HInstruction* double_box; | 9666 HInstruction* double_box; |
9630 if (data_target != NULL) { | 9667 if (data_target != NULL) { |
9631 double_box = Add<HInnerAllocatedObject>(data_target, *data_offset); | 9668 double_box = Add<HInnerAllocatedObject>(data_target, *data_offset); |
9632 *data_offset += HeapNumber::kSize; | 9669 *data_offset += HeapNumber::kSize; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9719 for (int i = 0; i < elements_length; i++) { | 9756 for (int i = 0; i < elements_length; i++) { |
9720 Handle<Object> value(fast_elements->get(i), isolate()); | 9757 Handle<Object> value(fast_elements->get(i), isolate()); |
9721 HValue* key_constant = Add<HConstant>(i); | 9758 HValue* key_constant = Add<HConstant>(i); |
9722 if (value->IsJSObject()) { | 9759 if (value->IsJSObject()) { |
9723 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9760 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
9724 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 9761 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
9725 Handle<Object>(original_fast_elements->get(i), isolate())); | 9762 Handle<Object>(original_fast_elements->get(i), isolate())); |
9726 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, | 9763 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, |
9727 *offset); | 9764 *offset); |
9728 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 9765 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
9729 BuildEmitDeepCopy(value_object, original_value_object, target, | 9766 BuildEmitDeepCopy(value_object, original_value_object, |
9730 offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); | 9767 Handle<Object>::null(), target, |
| 9768 offset, data_target, data_offset, |
| 9769 DONT_TRACK_ALLOCATION_SITE); |
9731 } else { | 9770 } else { |
9732 HInstruction* value_instruction = | 9771 HInstruction* value_instruction = |
9733 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 9772 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
9734 static_cast<HValue*>(NULL), kind, | 9773 static_cast<HValue*>(NULL), kind, |
9735 ALLOW_RETURN_HOLE); | 9774 ALLOW_RETURN_HOLE); |
9736 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 9775 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
9737 } | 9776 } |
9738 } | 9777 } |
9739 } | 9778 } |
9740 | 9779 |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11020 if (ShouldProduceTraceOutput()) { | 11059 if (ShouldProduceTraceOutput()) { |
11021 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11060 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11022 } | 11061 } |
11023 | 11062 |
11024 #ifdef DEBUG | 11063 #ifdef DEBUG |
11025 graph_->Verify(false); // No full verify. | 11064 graph_->Verify(false); // No full verify. |
11026 #endif | 11065 #endif |
11027 } | 11066 } |
11028 | 11067 |
11029 } } // namespace v8::internal | 11068 } } // namespace v8::internal |
OLD | NEW |