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 3600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3611 HInnerAllocatedObject::New(zone, context(), dominating_allocate_, | 3611 HInnerAllocatedObject::New(zone, context(), dominating_allocate_, |
3612 dominating_allocate_->size(), type()); | 3612 dominating_allocate_->size(), type()); |
3613 free_space_instr->InsertBefore(this); | 3613 free_space_instr->InsertBefore(this); |
3614 HConstant* filler_map = HConstant::New( | 3614 HConstant* filler_map = HConstant::New( |
3615 zone, | 3615 zone, |
3616 context(), | 3616 context(), |
3617 isolate()->factory()->free_space_map()); | 3617 isolate()->factory()->free_space_map()); |
3618 filler_map->FinalizeUniqueness(); // TODO(titzer): should be init'd a'ready | 3618 filler_map->FinalizeUniqueness(); // TODO(titzer): should be init'd a'ready |
3619 filler_map->InsertAfter(free_space_instr); | 3619 filler_map->InsertAfter(free_space_instr); |
3620 HInstruction* store_map = HStoreNamedField::New(zone, context(), | 3620 HInstruction* store_map = HStoreNamedField::New(zone, context(), |
3621 free_space_instr, HObjectAccess::ForMap(), filler_map, | 3621 free_space_instr, HObjectAccess::ForMap(), filler_map); |
3622 INITIALIZING_STORE); | |
3623 store_map->SetFlag(HValue::kHasNoObservableSideEffects); | 3622 store_map->SetFlag(HValue::kHasNoObservableSideEffects); |
3624 store_map->InsertAfter(filler_map); | 3623 store_map->InsertAfter(filler_map); |
3625 | 3624 |
3626 // We must explicitly force Smi representation here because on x64 we | 3625 // We must explicitly force Smi representation here because on x64 we |
3627 // would otherwise automatically choose int32, but the actual store | 3626 // would otherwise automatically choose int32, but the actual store |
3628 // requires a Smi-tagged value. | 3627 // requires a Smi-tagged value. |
3629 HConstant* filler_size = HConstant::CreateAndInsertAfter( | 3628 HConstant* filler_size = HConstant::CreateAndInsertAfter( |
3630 zone, context(), free_space_size, Representation::Smi(), store_map); | 3629 zone, context(), free_space_size, Representation::Smi(), store_map); |
3631 // Must force Smi representation for x64 (see comment above). | 3630 // Must force Smi representation for x64 (see comment above). |
3632 HObjectAccess access = | 3631 HObjectAccess access = |
3633 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset, | 3632 HObjectAccess::ForMapAndOffset(isolate()->factory()->free_space_map(), |
3634 Representation::Smi()); | 3633 FreeSpace::kSizeOffset, |
| 3634 Representation::Smi()); |
3635 HStoreNamedField* store_size = HStoreNamedField::New(zone, context(), | 3635 HStoreNamedField* store_size = HStoreNamedField::New(zone, context(), |
3636 free_space_instr, access, filler_size, INITIALIZING_STORE); | 3636 free_space_instr, access, filler_size); |
3637 store_size->SetFlag(HValue::kHasNoObservableSideEffects); | 3637 store_size->SetFlag(HValue::kHasNoObservableSideEffects); |
3638 store_size->InsertAfter(filler_size); | 3638 store_size->InsertAfter(filler_size); |
3639 filler_free_space_size_ = store_size; | 3639 filler_free_space_size_ = store_size; |
3640 } | 3640 } |
3641 | 3641 |
3642 | 3642 |
3643 void HAllocate::ClearNextMapWord(int offset) { | 3643 void HAllocate::ClearNextMapWord(int offset) { |
3644 if (MustClearNextMapWord()) { | 3644 if (MustClearNextMapWord()) { |
3645 Zone* zone = block()->zone(); | 3645 Zone* zone = block()->zone(); |
3646 HObjectAccess access = HObjectAccess::ForJSObjectOffset(offset); | 3646 HObjectAccess access = |
| 3647 HObjectAccess::ForObservableJSObjectOffset(offset); |
3647 HStoreNamedField* clear_next_map = | 3648 HStoreNamedField* clear_next_map = |
3648 HStoreNamedField::New(zone, context(), this, access, | 3649 HStoreNamedField::New(zone, context(), this, access, |
3649 block()->graph()->GetConstant0(), INITIALIZING_STORE); | 3650 block()->graph()->GetConstant0()); |
3650 clear_next_map->ClearAllSideEffects(); | 3651 clear_next_map->ClearAllSideEffects(); |
3651 clear_next_map->InsertAfter(this); | 3652 clear_next_map->InsertAfter(this); |
3652 } | 3653 } |
3653 } | 3654 } |
3654 | 3655 |
3655 | 3656 |
3656 void HAllocate::PrintDataTo(StringStream* stream) { | 3657 void HAllocate::PrintDataTo(StringStream* stream) { |
3657 size()->PrintNameTo(stream); | 3658 size()->PrintNameTo(stream); |
3658 stream->Add(" ("); | 3659 stream->Add(" ("); |
3659 if (IsNewSpaceAllocation()) stream->Add("N"); | 3660 if (IsNewSpaceAllocation()) stream->Add("N"); |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4263 | 4264 |
4264 | 4265 |
4265 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) { | 4266 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) { |
4266 ASSERT(offset >= 0); | 4267 ASSERT(offset >= 0); |
4267 ASSERT(offset < FixedArray::kHeaderSize); | 4268 ASSERT(offset < FixedArray::kHeaderSize); |
4268 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength(); | 4269 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength(); |
4269 return HObjectAccess(kInobject, offset); | 4270 return HObjectAccess(kInobject, offset); |
4270 } | 4271 } |
4271 | 4272 |
4272 | 4273 |
4273 HObjectAccess HObjectAccess::ForJSObjectOffset(int offset, | 4274 HObjectAccess HObjectAccess::ForMapAndOffset(Handle<Map> map, int offset, |
4274 Representation representation) { | 4275 Representation representation) { |
4275 ASSERT(offset >= 0); | 4276 ASSERT(offset >= 0); |
4276 Portion portion = kInobject; | 4277 Portion portion = kInobject; |
4277 | 4278 |
4278 if (offset == JSObject::kElementsOffset) { | 4279 if (offset == JSObject::kElementsOffset) { |
4279 portion = kElementsPointer; | 4280 portion = kElementsPointer; |
4280 } else if (offset == JSObject::kMapOffset) { | 4281 } else if (offset == JSObject::kMapOffset) { |
4281 portion = kMaps; | 4282 portion = kMaps; |
4282 } | 4283 } |
4283 return HObjectAccess(portion, offset, representation); | 4284 bool existing_inobject_property = true; |
| 4285 if (!map.is_null()) { |
| 4286 existing_inobject_property = (offset < |
| 4287 map->instance_size() - map->unused_property_fields() * kPointerSize); |
| 4288 } |
| 4289 return HObjectAccess(portion, offset, representation, Handle<String>::null(), |
| 4290 false, existing_inobject_property); |
4284 } | 4291 } |
4285 | 4292 |
4286 | 4293 |
4287 HObjectAccess HObjectAccess::ForAllocationSiteOffset(int offset) { | 4294 HObjectAccess HObjectAccess::ForAllocationSiteOffset(int offset) { |
4288 switch (offset) { | 4295 switch (offset) { |
4289 case AllocationSite::kTransitionInfoOffset: | 4296 case AllocationSite::kTransitionInfoOffset: |
4290 return HObjectAccess(kInobject, offset, Representation::Tagged()); | 4297 return HObjectAccess(kInobject, offset, Representation::Tagged()); |
4291 case AllocationSite::kNestedSiteOffset: | 4298 case AllocationSite::kNestedSiteOffset: |
4292 return HObjectAccess(kInobject, offset, Representation::Tagged()); | 4299 return HObjectAccess(kInobject, offset, Representation::Tagged()); |
4293 case AllocationSite::kPretenureDataOffset: | 4300 case AllocationSite::kPretenureDataOffset: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4325 } else if (offset == JSObject::kMapOffset) { | 4332 } else if (offset == JSObject::kMapOffset) { |
4326 portion = kMaps; | 4333 portion = kMaps; |
4327 } | 4334 } |
4328 return HObjectAccess(portion, offset); | 4335 return HObjectAccess(portion, offset); |
4329 } | 4336 } |
4330 | 4337 |
4331 | 4338 |
4332 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, | 4339 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, |
4333 Representation representation) { | 4340 Representation representation) { |
4334 ASSERT(offset >= 0); | 4341 ASSERT(offset >= 0); |
4335 return HObjectAccess(kBackingStore, offset, representation); | 4342 return HObjectAccess(kBackingStore, offset, representation, |
| 4343 Handle<String>::null(), false, false); |
4336 } | 4344 } |
4337 | 4345 |
4338 | 4346 |
4339 HObjectAccess HObjectAccess::ForField(Handle<Map> map, | 4347 HObjectAccess HObjectAccess::ForField(Handle<Map> map, |
4340 LookupResult *lookup, Handle<String> name) { | 4348 LookupResult *lookup, Handle<String> name) { |
4341 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); | 4349 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); |
4342 int index; | 4350 int index; |
4343 Representation representation; | 4351 Representation representation; |
4344 if (lookup->IsField()) { | 4352 if (lookup->IsField()) { |
4345 index = lookup->GetLocalFieldIndexFromMap(*map); | 4353 index = lookup->GetLocalFieldIndexFromMap(*map); |
4346 representation = lookup->representation(); | 4354 representation = lookup->representation(); |
4347 } else { | 4355 } else { |
4348 Map* transition = lookup->GetTransitionMapFromMap(*map); | 4356 Map* transition = lookup->GetTransitionMapFromMap(*map); |
4349 int descriptor = transition->LastAdded(); | 4357 int descriptor = transition->LastAdded(); |
4350 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - | 4358 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - |
4351 map->inobject_properties(); | 4359 map->inobject_properties(); |
4352 PropertyDetails details = | 4360 PropertyDetails details = |
4353 transition->instance_descriptors()->GetDetails(descriptor); | 4361 transition->instance_descriptors()->GetDetails(descriptor); |
4354 representation = details.representation(); | 4362 representation = details.representation(); |
4355 } | 4363 } |
4356 if (index < 0) { | 4364 if (index < 0) { |
4357 // Negative property indices are in-object properties, indexed | 4365 // Negative property indices are in-object properties, indexed |
4358 // from the end of the fixed part of the object. | 4366 // from the end of the fixed part of the object. |
4359 int offset = (index * kPointerSize) + map->instance_size(); | 4367 int offset = (index * kPointerSize) + map->instance_size(); |
4360 return HObjectAccess(kInobject, offset, representation, name); | 4368 return HObjectAccess(kInobject, offset, representation, name, false, true); |
4361 } else { | 4369 } else { |
4362 // Non-negative property indices are in the properties array. | 4370 // Non-negative property indices are in the properties array. |
4363 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; | 4371 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; |
4364 return HObjectAccess(kBackingStore, offset, representation, name); | 4372 return HObjectAccess(kBackingStore, offset, representation, name, |
| 4373 false, false); |
4365 } | 4374 } |
4366 } | 4375 } |
4367 | 4376 |
4368 | 4377 |
4369 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { | 4378 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { |
4370 return HObjectAccess( | 4379 return HObjectAccess( |
4371 kInobject, Cell::kValueOffset, Representation::Tagged(), | 4380 kInobject, Cell::kValueOffset, Representation::Tagged(), |
4372 Handle<String>(isolate->heap()->cell_value_string())); | 4381 Handle<String>(isolate->heap()->cell_value_string())); |
4373 } | 4382 } |
4374 | 4383 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4451 break; | 4460 break; |
4452 case kExternalMemory: | 4461 case kExternalMemory: |
4453 stream->Add("[external-memory]"); | 4462 stream->Add("[external-memory]"); |
4454 break; | 4463 break; |
4455 } | 4464 } |
4456 | 4465 |
4457 stream->Add("@%d", offset()); | 4466 stream->Add("@%d", offset()); |
4458 } | 4467 } |
4459 | 4468 |
4460 } } // namespace v8::internal | 4469 } } // namespace v8::internal |
OLD | NEW |