Chromium Code Reviews| 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) { |
|
Hannes Payer (out of office)
2013/07/03 15:26:45
I think we should assert that alloc_site is not Ha
mvstanton
2013/07/05 07:56:14
good idea, but I'll just check for a NULL pointer
| |
| 1690 HInnerAllocatedObject* alloc_site = Add<HInnerAllocatedObject>( | 1691 HInnerAllocatedObject* alloc_site_info = Add<HInnerAllocatedObject>( |
| 1691 previous_object, previous_object_size); | 1692 previous_object, previous_object_size); |
| 1692 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map()); | 1693 Handle<Map> alloc_site_info_map( |
| 1693 AddStoreMapConstant(alloc_site, alloc_site_map); | 1694 isolate()->heap()->allocation_site_info_map()); |
| 1694 HObjectAccess access = HObjectAccess::ForAllocationSitePayload(); | 1695 AddStoreMapConstant(alloc_site_info, alloc_site_info_map); |
| 1695 AddStore(alloc_site, access, payload); | 1696 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); |
| 1696 return alloc_site; | 1697 AddStore(alloc_site_info, access, alloc_site); |
| 1698 return alloc_site_info; | |
| 1697 } | 1699 } |
| 1698 | 1700 |
| 1699 | 1701 |
| 1700 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { | 1702 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { |
| 1701 // Get the global context, then the native context | 1703 // Get the global context, then the native context |
| 1702 HInstruction* global_object = Add<HGlobalObject>(context); | 1704 HInstruction* global_object = Add<HGlobalObject>(context); |
| 1703 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 1705 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
| 1704 GlobalObject::kNativeContextOffset); | 1706 GlobalObject::kNativeContextOffset); |
| 1705 return AddLoad(global_object, access); | 1707 return AddLoad(global_object, access); |
| 1706 } | 1708 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1719 ElementsKind kind, | 1721 ElementsKind kind, |
| 1720 HValue* allocation_site_payload, | 1722 HValue* allocation_site_payload, |
| 1721 HValue* constructor_function, | 1723 HValue* constructor_function, |
| 1722 AllocationSiteOverrideMode override_mode) : | 1724 AllocationSiteOverrideMode override_mode) : |
| 1723 builder_(builder), | 1725 builder_(builder), |
| 1724 kind_(kind), | 1726 kind_(kind), |
| 1725 allocation_site_payload_(allocation_site_payload), | 1727 allocation_site_payload_(allocation_site_payload), |
| 1726 constructor_function_(constructor_function) { | 1728 constructor_function_(constructor_function) { |
| 1727 mode_ = override_mode == DISABLE_ALLOCATION_SITES | 1729 mode_ = override_mode == DISABLE_ALLOCATION_SITES |
| 1728 ? DONT_TRACK_ALLOCATION_SITE | 1730 ? DONT_TRACK_ALLOCATION_SITE |
| 1729 : AllocationSiteInfo::GetMode(kind); | 1731 : AllocationSite::GetMode(kind); |
| 1730 } | 1732 } |
| 1731 | 1733 |
| 1732 | 1734 |
| 1733 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1735 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
| 1734 ElementsKind kind, | 1736 ElementsKind kind, |
| 1735 HValue* constructor_function) : | 1737 HValue* constructor_function) : |
| 1736 builder_(builder), | 1738 builder_(builder), |
| 1737 kind_(kind), | 1739 kind_(kind), |
| 1738 mode_(DONT_TRACK_ALLOCATION_SITE), | 1740 mode_(DONT_TRACK_ALLOCATION_SITE), |
| 1739 allocation_site_payload_(NULL), | 1741 allocation_site_payload_(NULL), |
| (...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5426 &data_size, | 5428 &data_size, |
| 5427 &pointer_size)) { | 5429 &pointer_size)) { |
| 5428 Handle<JSObject> original_boilerplate_object = | 5430 Handle<JSObject> original_boilerplate_object = |
| 5429 Handle<JSObject>::cast(original_boilerplate); | 5431 Handle<JSObject>::cast(original_boilerplate); |
| 5430 Handle<JSObject> boilerplate_object = | 5432 Handle<JSObject> boilerplate_object = |
| 5431 DeepCopy(original_boilerplate_object); | 5433 DeepCopy(original_boilerplate_object); |
| 5432 | 5434 |
| 5433 literal = BuildFastLiteral(context, | 5435 literal = BuildFastLiteral(context, |
| 5434 boilerplate_object, | 5436 boilerplate_object, |
| 5435 original_boilerplate_object, | 5437 original_boilerplate_object, |
| 5438 Handle<Object>::null(), | |
| 5436 data_size, | 5439 data_size, |
| 5437 pointer_size, | 5440 pointer_size, |
| 5438 DONT_TRACK_ALLOCATION_SITE); | 5441 DONT_TRACK_ALLOCATION_SITE); |
| 5439 } else { | 5442 } else { |
| 5440 NoObservableSideEffectsScope no_effects(this); | 5443 NoObservableSideEffectsScope no_effects(this); |
| 5441 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5444 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
| 5442 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5445 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 5443 int literal_index = expr->literal_index(); | 5446 int literal_index = expr->literal_index(); |
| 5444 int flags = expr->fast_elements() | 5447 int flags = expr->fast_elements() |
| 5445 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; | 5448 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5533 | 5536 |
| 5534 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 5537 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
| 5535 ASSERT(!HasStackOverflow()); | 5538 ASSERT(!HasStackOverflow()); |
| 5536 ASSERT(current_block() != NULL); | 5539 ASSERT(current_block() != NULL); |
| 5537 ASSERT(current_block()->HasPredecessor()); | 5540 ASSERT(current_block()->HasPredecessor()); |
| 5538 ZoneList<Expression*>* subexprs = expr->values(); | 5541 ZoneList<Expression*>* subexprs = expr->values(); |
| 5539 int length = subexprs->length(); | 5542 int length = subexprs->length(); |
| 5540 HValue* context = environment()->LookupContext(); | 5543 HValue* context = environment()->LookupContext(); |
| 5541 HInstruction* literal; | 5544 HInstruction* literal; |
| 5542 | 5545 |
| 5546 Handle<AllocationSite> site; | |
| 5543 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); | 5547 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); |
| 5544 Handle<Object> raw_boilerplate(literals->get(expr->literal_index()), | 5548 Handle<Object> literals_cell(literals->get(expr->literal_index()), |
| 5545 isolate()); | 5549 isolate()); |
|
Hannes Payer (out of office)
2013/07/03 15:26:45
indent
| |
| 5546 | 5550 Handle<Object> raw_boilerplate; |
| 5547 if (raw_boilerplate->IsUndefined()) { | 5551 if (literals_cell->IsUndefined()) { |
| 5548 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( | 5552 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( |
| 5549 isolate(), literals, expr->constant_elements()); | 5553 isolate(), literals, expr->constant_elements()); |
| 5550 if (raw_boilerplate.is_null()) { | 5554 if (raw_boilerplate.is_null()) { |
| 5551 return Bailout("array boilerplate creation failed"); | 5555 return Bailout("array boilerplate creation failed"); |
| 5552 } | 5556 } |
| 5553 literals->set(expr->literal_index(), *raw_boilerplate); | 5557 |
| 5558 site = isolate()->factory()->NewAllocationSite(); | |
| 5559 | |
| 5560 // We'll want to copy any useful information (statistics?) in the | |
| 5561 // AllocationSite from the full code gen | |
|
Hannes Payer (out of office)
2013/07/03 15:26:45
Is the uncommented code still needed? What about t
mvstanton
2013/07/05 07:56:14
Okay, I went ahead and removed this block, I reali
| |
| 5562 /* | |
| 5563 Handle<FixedArray> fullcode_literals(info()->closure()->literals(), isolate( )); | |
| 5564 Handle<Object> fullcode_literals_cell(fullcode_literals->get(expr->literal_i ndex()), | |
| 5565 isolate()); | |
| 5566 if (!fullcode_literals_cell->IsUndefined()) { | |
| 5567 Handle<AllocationSite> old_site = Handle<AllocationSite>::cast(fullcode_li terals_cell); | |
| 5568 // Extract info... | |
| 5569 } | |
| 5570 */ | |
| 5571 | |
| 5572 site->set_payload(*raw_boilerplate); | |
| 5573 literals->set(expr->literal_index(), *site); | |
| 5574 | |
| 5554 if (JSObject::cast(*raw_boilerplate)->elements()->map() == | 5575 if (JSObject::cast(*raw_boilerplate)->elements()->map() == |
| 5555 isolate()->heap()->fixed_cow_array_map()) { | 5576 isolate()->heap()->fixed_cow_array_map()) { |
| 5556 isolate()->counters()->cow_arrays_created_runtime()->Increment(); | 5577 isolate()->counters()->cow_arrays_created_runtime()->Increment(); |
| 5557 } | 5578 } |
| 5579 } else { | |
| 5580 ASSERT(literals_cell->IsAllocationSite()); | |
| 5581 site = Handle<AllocationSite>::cast(literals_cell); | |
| 5582 raw_boilerplate = Handle<Object>(site->payload(), isolate()); | |
| 5558 } | 5583 } |
| 5559 | 5584 |
| 5585 ASSERT(!raw_boilerplate.is_null()); | |
| 5586 ASSERT(site->IsLiteralSite()); | |
| 5587 | |
| 5560 Handle<JSObject> original_boilerplate_object = | 5588 Handle<JSObject> original_boilerplate_object = |
| 5561 Handle<JSObject>::cast(raw_boilerplate); | 5589 Handle<JSObject>::cast(raw_boilerplate); |
| 5562 ElementsKind boilerplate_elements_kind = | 5590 ElementsKind boilerplate_elements_kind = |
| 5563 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); | 5591 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); |
| 5564 | 5592 |
| 5565 // TODO(mvstanton): This heuristic is only a temporary solution. In the | 5593 // 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 | 5594 // end, we want to quit creating allocation site info after a certain number |
| 5567 // of GCs for a call site. | 5595 // of GCs for a call site. |
| 5568 AllocationSiteMode mode = AllocationSiteInfo::GetMode( | 5596 AllocationSiteMode mode = AllocationSite::GetMode( |
| 5569 boilerplate_elements_kind); | 5597 boilerplate_elements_kind); |
| 5570 | 5598 |
| 5571 // Check whether to use fast or slow deep-copying for boilerplate. | 5599 // Check whether to use fast or slow deep-copying for boilerplate. |
| 5572 int data_size = 0; | 5600 int data_size = 0; |
| 5573 int pointer_size = 0; | 5601 int pointer_size = 0; |
| 5574 int max_properties = kMaxFastLiteralProperties; | 5602 int max_properties = kMaxFastLiteralProperties; |
| 5575 if (IsFastLiteral(original_boilerplate_object, | 5603 if (IsFastLiteral(original_boilerplate_object, |
| 5576 kMaxFastLiteralDepth, | 5604 kMaxFastLiteralDepth, |
| 5577 &max_properties, | 5605 &max_properties, |
| 5578 &data_size, | 5606 &data_size, |
| 5579 &pointer_size)) { | 5607 &pointer_size)) { |
| 5580 if (mode == TRACK_ALLOCATION_SITE) { | 5608 if (mode == TRACK_ALLOCATION_SITE) { |
| 5581 pointer_size += AllocationSiteInfo::kSize; | 5609 pointer_size += AllocationSiteInfo::kSize; |
| 5582 } | 5610 } |
| 5583 | 5611 |
| 5584 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); | 5612 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); |
| 5585 literal = BuildFastLiteral(context, | 5613 literal = BuildFastLiteral(context, |
| 5586 boilerplate_object, | 5614 boilerplate_object, |
| 5587 original_boilerplate_object, | 5615 original_boilerplate_object, |
| 5616 site, | |
| 5588 data_size, | 5617 data_size, |
| 5589 pointer_size, | 5618 pointer_size, |
| 5590 mode); | 5619 mode); |
| 5591 } else { | 5620 } else { |
| 5592 NoObservableSideEffectsScope no_effects(this); | 5621 NoObservableSideEffectsScope no_effects(this); |
| 5593 // Boilerplate already exists and constant elements are never accessed, | 5622 // Boilerplate already exists and constant elements are never accessed, |
| 5594 // pass an empty fixed array to the runtime function instead. | 5623 // pass an empty fixed array to the runtime function instead. |
| 5595 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 5624 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
| 5596 int literal_index = expr->literal_index(); | 5625 int literal_index = expr->literal_index(); |
| 5597 | 5626 |
| (...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9414 } else { | 9443 } else { |
| 9415 return new(zone()) HThisFunction; | 9444 return new(zone()) HThisFunction; |
| 9416 } | 9445 } |
| 9417 } | 9446 } |
| 9418 | 9447 |
| 9419 | 9448 |
| 9420 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( | 9449 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
| 9421 HValue* context, | 9450 HValue* context, |
| 9422 Handle<JSObject> boilerplate_object, | 9451 Handle<JSObject> boilerplate_object, |
| 9423 Handle<JSObject> original_boilerplate_object, | 9452 Handle<JSObject> original_boilerplate_object, |
| 9453 Handle<Object> allocation_site, | |
| 9424 int data_size, | 9454 int data_size, |
| 9425 int pointer_size, | 9455 int pointer_size, |
| 9426 AllocationSiteMode mode) { | 9456 AllocationSiteMode mode) { |
| 9427 NoObservableSideEffectsScope no_effects(this); | 9457 NoObservableSideEffectsScope no_effects(this); |
| 9428 | 9458 |
| 9429 HInstruction* target = NULL; | 9459 HInstruction* target = NULL; |
| 9430 HInstruction* data_target = NULL; | 9460 HInstruction* data_target = NULL; |
| 9431 | 9461 |
| 9432 HAllocate::Flags flags = HAllocate::DefaultFlags(); | 9462 HAllocate::Flags flags = HAllocate::DefaultFlags(); |
| 9433 | 9463 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 9451 HValue* size_in_bytes = Add<HConstant>(pointer_size); | 9481 HValue* size_in_bytes = Add<HConstant>(pointer_size); |
| 9452 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); | 9482 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); |
| 9453 } | 9483 } |
| 9454 } else { | 9484 } else { |
| 9455 HValue* size_in_bytes = Add<HConstant>(data_size + pointer_size); | 9485 HValue* size_in_bytes = Add<HConstant>(data_size + pointer_size); |
| 9456 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); | 9486 target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), flags); |
| 9457 } | 9487 } |
| 9458 | 9488 |
| 9459 int offset = 0; | 9489 int offset = 0; |
| 9460 int data_offset = 0; | 9490 int data_offset = 0; |
| 9461 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, target, | 9491 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, |
| 9462 &offset, data_target, &data_offset, mode); | 9492 allocation_site, target, &offset, data_target, |
| 9493 &data_offset, mode); | |
| 9463 return target; | 9494 return target; |
| 9464 } | 9495 } |
| 9465 | 9496 |
| 9466 | 9497 |
| 9467 void HOptimizedGraphBuilder::BuildEmitDeepCopy( | 9498 void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
| 9468 Handle<JSObject> boilerplate_object, | 9499 Handle<JSObject> boilerplate_object, |
| 9469 Handle<JSObject> original_boilerplate_object, | 9500 Handle<JSObject> original_boilerplate_object, |
| 9501 Handle<Object> allocation_site_object, | |
| 9470 HInstruction* target, | 9502 HInstruction* target, |
| 9471 int* offset, | 9503 int* offset, |
| 9472 HInstruction* data_target, | 9504 HInstruction* data_target, |
| 9473 int* data_offset, | 9505 int* data_offset, |
| 9474 AllocationSiteMode mode) { | 9506 AllocationSiteMode mode) { |
| 9507 Zone* zone = this->zone(); | |
| 9508 | |
| 9509 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && | |
| 9510 boilerplate_object->map()->CanTrackAllocationSite(); | |
| 9511 | |
| 9512 // If using allocation sites, then the payload on the site should already | |
| 9513 // be filled in as a valid (boilerplate) array. | |
| 9514 ASSERT(!create_allocation_site_info || | |
| 9515 AllocationSite::cast(*allocation_site_object)->IsLiteralSite()); | |
| 9516 | |
| 9517 HInstruction* allocation_site = NULL; | |
| 9518 | |
| 9519 if (create_allocation_site_info) { | |
| 9520 allocation_site = AddInstruction(new(zone) HConstant( | |
| 9521 allocation_site_object, Representation::Tagged())); | |
| 9522 } | |
| 9523 | |
| 9524 // Only elements backing stores for non-COW arrays need to be copied. | |
| 9475 Handle<FixedArrayBase> elements(boilerplate_object->elements()); | 9525 Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
| 9476 Handle<FixedArrayBase> original_elements( | 9526 Handle<FixedArrayBase> original_elements( |
| 9477 original_boilerplate_object->elements()); | 9527 original_boilerplate_object->elements()); |
| 9478 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 9528 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
| 9479 | 9529 |
| 9480 int object_offset = *offset; | 9530 int object_offset = *offset; |
| 9481 int object_size = boilerplate_object->map()->instance_size(); | 9531 int object_size = boilerplate_object->map()->instance_size(); |
| 9482 int elements_size = (elements->length() > 0 && | 9532 int elements_size = (elements->length() > 0 && |
| 9483 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? | 9533 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? |
| 9484 elements->Size() : 0; | 9534 elements->Size() : 0; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 9510 Add<HInnerAllocatedObject>(target, object_offset); | 9560 Add<HInnerAllocatedObject>(target, object_offset); |
| 9511 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, | 9561 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, |
| 9512 object_properties, target, offset, data_target, data_offset); | 9562 object_properties, target, offset, data_target, data_offset); |
| 9513 } | 9563 } |
| 9514 | 9564 |
| 9515 // Create allocation site info. | 9565 // Create allocation site info. |
| 9516 if (mode == TRACK_ALLOCATION_SITE && | 9566 if (mode == TRACK_ALLOCATION_SITE && |
| 9517 boilerplate_object->map()->CanTrackAllocationSite()) { | 9567 boilerplate_object->map()->CanTrackAllocationSite()) { |
| 9518 elements_offset += AllocationSiteInfo::kSize; | 9568 elements_offset += AllocationSiteInfo::kSize; |
| 9519 *offset += AllocationSiteInfo::kSize; | 9569 *offset += AllocationSiteInfo::kSize; |
| 9520 HInstruction* original_boilerplate = | 9570 BuildCreateAllocationSiteInfo(target, JSArray::kSize, allocation_site); |
| 9521 Add<HConstant>(original_boilerplate_object); | |
| 9522 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); | |
| 9523 } | 9571 } |
| 9524 } | 9572 } |
| 9525 | 9573 |
| 9526 | 9574 |
| 9527 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( | 9575 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( |
| 9528 Handle<JSObject> boilerplate_object, | 9576 Handle<JSObject> boilerplate_object, |
| 9529 HInstruction* target, | 9577 HInstruction* target, |
| 9530 HInstruction* data_target, | 9578 HInstruction* data_target, |
| 9531 int object_offset, | 9579 int object_offset, |
| 9532 int elements_offset, | 9580 int elements_offset, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9610 | 9658 |
| 9611 if (value->IsJSObject()) { | 9659 if (value->IsJSObject()) { |
| 9612 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9660 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 9613 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 9661 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
| 9614 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), | 9662 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), |
| 9615 isolate())); | 9663 isolate())); |
| 9616 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, | 9664 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, |
| 9617 *offset); | 9665 *offset); |
| 9618 | 9666 |
| 9619 AddStore(object_properties, access, value_instruction); | 9667 AddStore(object_properties, access, value_instruction); |
| 9620 | 9668 BuildEmitDeepCopy(value_object, original_value_object, |
| 9621 BuildEmitDeepCopy(value_object, original_value_object, target, | 9669 Handle<Object>::null(), target, |
| 9622 offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); | 9670 offset, data_target, data_offset, |
| 9671 DONT_TRACK_ALLOCATION_SITE); | |
| 9623 } else { | 9672 } else { |
| 9624 Representation representation = details.representation(); | 9673 Representation representation = details.representation(); |
| 9625 HInstruction* value_instruction = Add<HConstant>(value); | 9674 HInstruction* value_instruction = Add<HConstant>(value); |
| 9626 | 9675 |
| 9627 if (representation.IsDouble()) { | 9676 if (representation.IsDouble()) { |
| 9628 // Allocate a HeapNumber box and store the value into it. | 9677 // Allocate a HeapNumber box and store the value into it. |
| 9629 HInstruction* double_box; | 9678 HInstruction* double_box; |
| 9630 if (data_target != NULL) { | 9679 if (data_target != NULL) { |
| 9631 double_box = Add<HInnerAllocatedObject>(data_target, *data_offset); | 9680 double_box = Add<HInnerAllocatedObject>(data_target, *data_offset); |
| 9632 *data_offset += HeapNumber::kSize; | 9681 *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++) { | 9768 for (int i = 0; i < elements_length; i++) { |
| 9720 Handle<Object> value(fast_elements->get(i), isolate()); | 9769 Handle<Object> value(fast_elements->get(i), isolate()); |
| 9721 HValue* key_constant = Add<HConstant>(i); | 9770 HValue* key_constant = Add<HConstant>(i); |
| 9722 if (value->IsJSObject()) { | 9771 if (value->IsJSObject()) { |
| 9723 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9772 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 9724 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 9773 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
| 9725 Handle<Object>(original_fast_elements->get(i), isolate())); | 9774 Handle<Object>(original_fast_elements->get(i), isolate())); |
| 9726 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, | 9775 HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, |
| 9727 *offset); | 9776 *offset); |
| 9728 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 9777 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
| 9729 BuildEmitDeepCopy(value_object, original_value_object, target, | 9778 BuildEmitDeepCopy(value_object, original_value_object, |
| 9730 offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); | 9779 Handle<Object>::null(), target, |
| 9780 offset, data_target, data_offset, | |
| 9781 DONT_TRACK_ALLOCATION_SITE); | |
| 9731 } else { | 9782 } else { |
| 9732 HInstruction* value_instruction = | 9783 HInstruction* value_instruction = |
| 9733 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 9784 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
| 9734 static_cast<HValue*>(NULL), kind, | 9785 static_cast<HValue*>(NULL), kind, |
| 9735 ALLOW_RETURN_HOLE); | 9786 ALLOW_RETURN_HOLE); |
| 9736 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 9787 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
| 9737 } | 9788 } |
| 9738 } | 9789 } |
| 9739 } | 9790 } |
| 9740 | 9791 |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11020 if (ShouldProduceTraceOutput()) { | 11071 if (ShouldProduceTraceOutput()) { |
| 11021 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11072 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 11022 } | 11073 } |
| 11023 | 11074 |
| 11024 #ifdef DEBUG | 11075 #ifdef DEBUG |
| 11025 graph_->Verify(false); // No full verify. | 11076 graph_->Verify(false); // No full verify. |
| 11026 #endif | 11077 #endif |
| 11027 } | 11078 } |
| 11028 | 11079 |
| 11029 } } // namespace v8::internal | 11080 } } // namespace v8::internal |
| OLD | NEW |