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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 316023002: --debug-code: sanity-checking instrumentation for Lithium object accesses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/double.h" 7 #include "src/double.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/hydrogen-infer-representation.h" 9 #include "src/hydrogen-infer-representation.h"
10 #include "src/property-details-inl.h" 10 #include "src/property-details-inl.h"
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 4008
4009 // We must explicitly force Smi representation here because on x64 we 4009 // We must explicitly force Smi representation here because on x64 we
4010 // would otherwise automatically choose int32, but the actual store 4010 // would otherwise automatically choose int32, but the actual store
4011 // requires a Smi-tagged value. 4011 // requires a Smi-tagged value.
4012 HConstant* filler_size = HConstant::CreateAndInsertAfter( 4012 HConstant* filler_size = HConstant::CreateAndInsertAfter(
4013 zone, context(), free_space_size, Representation::Smi(), store_map); 4013 zone, context(), free_space_size, Representation::Smi(), store_map);
4014 // Must force Smi representation for x64 (see comment above). 4014 // Must force Smi representation for x64 (see comment above).
4015 HObjectAccess access = 4015 HObjectAccess access =
4016 HObjectAccess::ForMapAndOffset(isolate()->factory()->free_space_map(), 4016 HObjectAccess::ForMapAndOffset(isolate()->factory()->free_space_map(),
4017 FreeSpace::kSizeOffset, 4017 FreeSpace::kSizeOffset,
4018 HObjectAccess::FOR_FIELD,
4018 Representation::Smi()); 4019 Representation::Smi());
4019 HStoreNamedField* store_size = HStoreNamedField::New(zone, context(), 4020 HStoreNamedField* store_size = HStoreNamedField::New(zone, context(),
4020 free_space_instr, access, filler_size); 4021 free_space_instr, access, filler_size);
4021 store_size->SetFlag(HValue::kHasNoObservableSideEffects); 4022 store_size->SetFlag(HValue::kHasNoObservableSideEffects);
4022 store_size->InsertAfter(filler_size); 4023 store_size->InsertAfter(filler_size);
4023 filler_free_space_size_ = store_size; 4024 filler_free_space_size_ = store_size;
4024 } 4025 }
4025 4026
4026 4027
4027 void HAllocate::ClearNextMapWord(int offset) { 4028 void HAllocate::ClearNextMapWord(int offset) {
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4602 ASSERT(HasNoUses()); 4603 ASSERT(HasNoUses());
4603 } 4604 }
4604 4605
4605 #endif 4606 #endif
4606 4607
4607 4608
4608 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) { 4609 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) {
4609 ASSERT(offset >= 0); 4610 ASSERT(offset >= 0);
4610 ASSERT(offset < FixedArray::kHeaderSize); 4611 ASSERT(offset < FixedArray::kHeaderSize);
4611 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength(); 4612 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength();
4612 return HObjectAccess(kInobject, offset); 4613 return HObjectAccess(kInobject, offset, FOR_FIXED_ARRAY_HEADER);
4613 } 4614 }
4614 4615
4615 4616
4616 HObjectAccess HObjectAccess::ForMapAndOffset(Handle<Map> map, int offset, 4617 HObjectAccess HObjectAccess::ForMapAndOffset(Handle<Map> map, int offset,
4617 Representation representation) { 4618 Purpose purpose, Representation representation) {
4618 ASSERT(offset >= 0); 4619 ASSERT(offset >= 0);
4619 Portion portion = kInobject; 4620 Portion portion = kInobject;
4620 4621
4621 if (offset == JSObject::kElementsOffset) { 4622 if (offset == JSObject::kElementsOffset &&
4623 !map.is_null() && map->has_elements()) {
4622 portion = kElementsPointer; 4624 portion = kElementsPointer;
4625 purpose = FOR_ELEMENTS_POINTER;
4623 } else if (offset == JSObject::kMapOffset) { 4626 } else if (offset == JSObject::kMapOffset) {
4624 portion = kMaps; 4627 portion = kMaps;
4628 purpose = FOR_MAP;
4625 } 4629 }
4626 bool existing_inobject_property = true; 4630 bool existing_inobject_property = true;
4627 if (!map.is_null()) { 4631 if (!map.is_null()) {
4628 existing_inobject_property = (offset < 4632 existing_inobject_property = (offset <
4629 map->instance_size() - map->unused_property_fields() * kPointerSize); 4633 map->instance_size() - map->unused_property_fields() * kPointerSize);
4630 } 4634 }
4631 return HObjectAccess(portion, offset, representation, Handle<String>::null(), 4635 return HObjectAccess(portion, offset, purpose, representation,
4632 false, existing_inobject_property); 4636 Handle<String>::null(), false,
4637 existing_inobject_property);
4633 } 4638 }
4634 4639
4635 4640
4636 HObjectAccess HObjectAccess::ForAllocationSiteOffset(int offset) { 4641 HObjectAccess HObjectAccess::ForAllocationSiteOffset(int offset) {
4637 switch (offset) { 4642 switch (offset) {
4638 case AllocationSite::kTransitionInfoOffset: 4643 case AllocationSite::kTransitionInfoOffset:
Igor Sheludko 2014/06/05 09:04:30 While we are here, does it make sense to merge com
Jakob Kummerow 2014/06/05 14:33:31 Done.
4639 return HObjectAccess(kInobject, offset, Representation::Tagged()); 4644 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4645 Representation::Tagged());
4640 case AllocationSite::kNestedSiteOffset: 4646 case AllocationSite::kNestedSiteOffset:
4641 return HObjectAccess(kInobject, offset, Representation::Tagged()); 4647 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4648 Representation::Tagged());
4642 case AllocationSite::kPretenureDataOffset: 4649 case AllocationSite::kPretenureDataOffset:
4643 return HObjectAccess(kInobject, offset, Representation::Smi()); 4650 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4651 Representation::Smi());
4644 case AllocationSite::kPretenureCreateCountOffset: 4652 case AllocationSite::kPretenureCreateCountOffset:
4645 return HObjectAccess(kInobject, offset, Representation::Smi()); 4653 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4654 Representation::Smi());
4646 case AllocationSite::kDependentCodeOffset: 4655 case AllocationSite::kDependentCodeOffset:
4647 return HObjectAccess(kInobject, offset, Representation::Tagged()); 4656 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4657 Representation::Tagged());
4648 case AllocationSite::kWeakNextOffset: 4658 case AllocationSite::kWeakNextOffset:
4649 return HObjectAccess(kInobject, offset, Representation::Tagged()); 4659 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET,
4660 Representation::Tagged());
4650 default: 4661 default:
4651 UNREACHABLE(); 4662 UNREACHABLE();
4652 } 4663 }
4653 return HObjectAccess(kInobject, offset); 4664 return HObjectAccess(kInobject, offset, FOR_ALLOCATION_SITE_OFFSET);
4654 } 4665 }
4655 4666
4656 4667
4657 HObjectAccess HObjectAccess::ForContextSlot(int index) { 4668 HObjectAccess HObjectAccess::ForContextSlot(int index) {
4658 ASSERT(index >= 0); 4669 ASSERT(index >= 0);
4659 Portion portion = kInobject; 4670 Portion portion = kInobject;
4660 int offset = Context::kHeaderSize + index * kPointerSize; 4671 int offset = Context::kHeaderSize + index * kPointerSize;
4661 ASSERT_EQ(offset, Context::SlotOffset(index) + kHeapObjectTag); 4672 ASSERT_EQ(offset, Context::SlotOffset(index) + kHeapObjectTag);
4662 return HObjectAccess(portion, offset, Representation::Tagged()); 4673 return HObjectAccess(portion, offset, FOR_CONTEXT_SLOT,
4674 Representation::Tagged());
4663 } 4675 }
4664 4676
4665 4677
4666 HObjectAccess HObjectAccess::ForJSArrayOffset(int offset) { 4678 HObjectAccess HObjectAccess::ForJSArrayOffset(int offset) {
4667 ASSERT(offset >= 0); 4679 ASSERT(offset >= 0);
4668 Portion portion = kInobject; 4680 Portion portion = kInobject;
4681 Purpose purpose = FOR_JSARRAY_OFFSET;
4669 4682
4670 if (offset == JSObject::kElementsOffset) { 4683 if (offset == JSObject::kElementsOffset) {
4671 portion = kElementsPointer; 4684 portion = kElementsPointer;
4685 purpose = FOR_ELEMENTS_POINTER;
4672 } else if (offset == JSArray::kLengthOffset) { 4686 } else if (offset == JSArray::kLengthOffset) {
4673 portion = kArrayLengths; 4687 portion = kArrayLengths;
4688 purpose = FOR_ARRAY_LENGTH;
4674 } else if (offset == JSObject::kMapOffset) { 4689 } else if (offset == JSObject::kMapOffset) {
4675 portion = kMaps; 4690 portion = kMaps;
4691 purpose = FOR_MAP;
4676 } 4692 }
4677 return HObjectAccess(portion, offset); 4693 return HObjectAccess(portion, offset, purpose);
4678 } 4694 }
4679 4695
4680 4696
4681 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, 4697 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset,
4682 Representation representation) { 4698 Representation representation) {
4683 ASSERT(offset >= 0); 4699 ASSERT(offset >= 0);
4684 return HObjectAccess(kBackingStore, offset, representation, 4700 return HObjectAccess(kBackingStore, offset, FOR_BACKING_STORE_OFFSET,
4685 Handle<String>::null(), false, false); 4701 representation, Handle<String>::null(), false, false);
4686 } 4702 }
4687 4703
4688 4704
4689 HObjectAccess HObjectAccess::ForField(Handle<Map> map, 4705 HObjectAccess HObjectAccess::ForField(Handle<Map> map,
4690 LookupResult* lookup, 4706 LookupResult* lookup,
4691 Handle<String> name) { 4707 Handle<String> name) {
4692 ASSERT(lookup->IsField() || lookup->IsTransitionToField()); 4708 ASSERT(lookup->IsField() || lookup->IsTransitionToField());
4693 int index; 4709 int index;
4694 Representation representation; 4710 Representation representation;
4695 if (lookup->IsField()) { 4711 if (lookup->IsField()) {
4696 index = lookup->GetLocalFieldIndexFromMap(*map); 4712 index = lookup->GetLocalFieldIndexFromMap(*map);
4697 representation = lookup->representation(); 4713 representation = lookup->representation();
4698 } else { 4714 } else {
4699 Map* transition = lookup->GetTransitionTarget(); 4715 Map* transition = lookup->GetTransitionTarget();
4700 int descriptor = transition->LastAdded(); 4716 int descriptor = transition->LastAdded();
4701 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - 4717 index = transition->instance_descriptors()->GetFieldIndex(descriptor) -
4702 map->inobject_properties(); 4718 map->inobject_properties();
4703 PropertyDetails details = 4719 PropertyDetails details =
4704 transition->instance_descriptors()->GetDetails(descriptor); 4720 transition->instance_descriptors()->GetDetails(descriptor);
4705 representation = details.representation(); 4721 representation = details.representation();
4706 } 4722 }
4707 if (index < 0) { 4723 if (index < 0) {
4708 // Negative property indices are in-object properties, indexed 4724 // Negative property indices are in-object properties, indexed
4709 // from the end of the fixed part of the object. 4725 // from the end of the fixed part of the object.
4710 int offset = (index * kPointerSize) + map->instance_size(); 4726 int offset = (index * kPointerSize) + map->instance_size();
4711 return HObjectAccess(kInobject, offset, representation, name, false, true); 4727 return HObjectAccess(kInobject, offset, FOR_FIELD, representation, name,
4728 false, true);
4712 } else { 4729 } else {
4713 // Non-negative property indices are in the properties array. 4730 // Non-negative property indices are in the properties array.
4714 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; 4731 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
4715 return HObjectAccess(kBackingStore, offset, representation, name, 4732 return HObjectAccess(kBackingStore, offset, FOR_BACKING_STORE_OFFSET,
4716 false, false); 4733 representation, name, false, false);
4717 } 4734 }
4718 } 4735 }
4719 4736
4720 4737
4721 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { 4738 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) {
4722 return HObjectAccess( 4739 return HObjectAccess(
4723 kInobject, Cell::kValueOffset, Representation::Tagged(), 4740 kInobject, Cell::kValueOffset, FOR_CELL_PAYLOAD, Representation::Tagged(),
4724 Handle<String>(isolate->heap()->cell_value_string())); 4741 Handle<String>(isolate->heap()->cell_value_string()));
4725 } 4742 }
4726 4743
4727 4744
4728 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) { 4745 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) {
4729 // set the appropriate GVN flags for a given load or store instruction 4746 // set the appropriate GVN flags for a given load or store instruction
4730 if (access_type == STORE) { 4747 if (access_type == STORE) {
4731 // track dominating allocations in order to eliminate write barriers 4748 // track dominating allocations in order to eliminate write barriers
4732 instr->SetDependsOnFlag(::v8::internal::kNewSpacePromotion); 4749 instr->SetDependsOnFlag(::v8::internal::kNewSpacePromotion);
4733 instr->SetFlag(HValue::kTrackSideEffectDominators); 4750 instr->SetFlag(HValue::kTrackSideEffectDominators);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4827 break; 4844 break;
4828 case kExternalMemory: 4845 case kExternalMemory:
4829 stream->Add("[external-memory]"); 4846 stream->Add("[external-memory]");
4830 break; 4847 break;
4831 } 4848 }
4832 4849
4833 stream->Add("@%d", offset()); 4850 stream->Add("@%d", offset());
4834 } 4851 }
4835 4852
4836 } } // namespace v8::internal 4853 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698