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

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

Issue 144423010: Improve inobject field tracking during GVN. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 10 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
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/hydrogen-load-elimination.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 597
598 598
599 void HValue::PrintChangesTo(StringStream* stream) { 599 void HValue::PrintChangesTo(StringStream* stream) {
600 GVNFlagSet changes_flags = ChangesFlags(); 600 GVNFlagSet changes_flags = ChangesFlags();
601 if (changes_flags.IsEmpty()) return; 601 if (changes_flags.IsEmpty()) return;
602 stream->Add(" changes["); 602 stream->Add(" changes[");
603 if (changes_flags == AllSideEffectsFlagSet()) { 603 if (changes_flags == AllSideEffectsFlagSet()) {
604 stream->Add("*"); 604 stream->Add("*");
605 } else { 605 } else {
606 bool add_comma = false; 606 bool add_comma = false;
607 #define PRINT_DO(type) \ 607 #define PRINT_DO(Type) \
608 if (changes_flags.Contains(kChanges##type)) { \ 608 if (changes_flags.Contains(k##Type)) { \
609 if (add_comma) stream->Add(","); \ 609 if (add_comma) stream->Add(","); \
610 add_comma = true; \ 610 add_comma = true; \
611 stream->Add(#type); \ 611 stream->Add(#Type); \
612 } 612 }
613 GVN_TRACKED_FLAG_LIST(PRINT_DO); 613 GVN_TRACKED_FLAG_LIST(PRINT_DO);
614 GVN_UNTRACKED_FLAG_LIST(PRINT_DO); 614 GVN_UNTRACKED_FLAG_LIST(PRINT_DO);
615 #undef PRINT_DO 615 #undef PRINT_DO
616 } 616 }
617 stream->Add("]"); 617 stream->Add("]");
618 } 618 }
619 619
620 620
621 void HValue::PrintNameTo(StringStream* stream) { 621 void HValue::PrintNameTo(StringStream* stream) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 *tag = kInternalizedTag; 1509 *tag = kInternalizedTag;
1510 return; 1510 return;
1511 default: 1511 default:
1512 UNREACHABLE(); 1512 UNREACHABLE();
1513 } 1513 }
1514 } 1514 }
1515 1515
1516 1516
1517 bool HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, 1517 bool HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect,
1518 HValue* dominator) { 1518 HValue* dominator) {
1519 ASSERT(side_effect == kChangesMaps); 1519 ASSERT(side_effect == kMaps);
1520 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once 1520 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once
1521 // type information is rich enough we should generalize this to any HType 1521 // type information is rich enough we should generalize this to any HType
1522 // for which the map is known. 1522 // for which the map is known.
1523 if (HasNoUses() && dominator->IsStoreNamedField()) { 1523 if (HasNoUses() && dominator->IsStoreNamedField()) {
1524 HStoreNamedField* store = HStoreNamedField::cast(dominator); 1524 HStoreNamedField* store = HStoreNamedField::cast(dominator);
1525 if (!store->has_transition() || store->object() != value()) return false; 1525 if (!store->has_transition() || store->object() != value()) return false;
1526 HConstant* transition = HConstant::cast(store->transition()); 1526 HConstant* transition = HConstant::cast(store->transition());
1527 if (map_set_.Contains(transition->GetUnique())) { 1527 if (map_set_.Contains(transition->GetUnique())) {
1528 DeleteAndReplaceWith(NULL); 1528 DeleteAndReplaceWith(NULL);
1529 return true; 1529 return true;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 1617
1618 1618
1619 Range* HChange::InferRange(Zone* zone) { 1619 Range* HChange::InferRange(Zone* zone) {
1620 Range* input_range = value()->range(); 1620 Range* input_range = value()->range();
1621 if (from().IsInteger32() && !value()->CheckFlag(HInstruction::kUint32) && 1621 if (from().IsInteger32() && !value()->CheckFlag(HInstruction::kUint32) &&
1622 (to().IsSmi() || 1622 (to().IsSmi() ||
1623 (to().IsTagged() && 1623 (to().IsTagged() &&
1624 input_range != NULL && 1624 input_range != NULL &&
1625 input_range->IsInSmiRange()))) { 1625 input_range->IsInSmiRange()))) {
1626 set_type(HType::Smi()); 1626 set_type(HType::Smi());
1627 ClearGVNFlag(kChangesNewSpacePromotion); 1627 ClearChangesFlag(kNewSpacePromotion);
1628 } 1628 }
1629 Range* result = (input_range != NULL) 1629 Range* result = (input_range != NULL)
1630 ? input_range->Copy(zone) 1630 ? input_range->Copy(zone)
1631 : HValue::InferRange(zone); 1631 : HValue::InferRange(zone);
1632 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() || 1632 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() ||
1633 !(CheckFlag(kAllUsesTruncatingToInt32) || 1633 !(CheckFlag(kAllUsesTruncatingToInt32) ||
1634 CheckFlag(kAllUsesTruncatingToSmi))); 1634 CheckFlag(kAllUsesTruncatingToSmi)));
1635 if (to().IsSmi()) result->ClampToSmi(); 1635 if (to().IsSmi()) result->ClampToSmi();
1636 return result; 1636 return result;
1637 } 1637 }
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 Representation input_rep = value()->representation(); 3405 Representation input_rep = value()->representation();
3406 if (!input_rep.IsTagged()) { 3406 if (!input_rep.IsTagged()) {
3407 rep = rep.generalize(input_rep); 3407 rep = rep.generalize(input_rep);
3408 } 3408 }
3409 return rep; 3409 return rep;
3410 } 3410 }
3411 3411
3412 3412
3413 bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, 3413 bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
3414 HValue* dominator) { 3414 HValue* dominator) {
3415 ASSERT(side_effect == kChangesNewSpacePromotion); 3415 ASSERT(side_effect == kNewSpacePromotion);
3416 Zone* zone = block()->zone(); 3416 Zone* zone = block()->zone();
3417 if (!FLAG_use_allocation_folding) return false; 3417 if (!FLAG_use_allocation_folding) return false;
3418 3418
3419 // Try to fold allocations together with their dominating allocations. 3419 // Try to fold allocations together with their dominating allocations.
3420 if (!dominator->IsAllocate()) { 3420 if (!dominator->IsAllocate()) {
3421 if (FLAG_trace_allocation_folding) { 3421 if (FLAG_trace_allocation_folding) {
3422 PrintF("#%d (%s) cannot fold into #%d (%s)\n", 3422 PrintF("#%d (%s) cannot fold into #%d (%s)\n",
3423 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); 3423 id(), Mnemonic(), dominator->id(), dominator->Mnemonic());
3424 } 3424 }
3425 return false; 3425 return false;
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4387 return HObjectAccess( 4387 return HObjectAccess(
4388 kInobject, Cell::kValueOffset, Representation::Tagged(), 4388 kInobject, Cell::kValueOffset, Representation::Tagged(),
4389 Handle<String>(isolate->heap()->cell_value_string())); 4389 Handle<String>(isolate->heap()->cell_value_string()));
4390 } 4390 }
4391 4391
4392 4392
4393 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) { 4393 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) {
4394 // set the appropriate GVN flags for a given load or store instruction 4394 // set the appropriate GVN flags for a given load or store instruction
4395 if (access_type == STORE) { 4395 if (access_type == STORE) {
4396 // track dominating allocations in order to eliminate write barriers 4396 // track dominating allocations in order to eliminate write barriers
4397 instr->SetGVNFlag(kDependsOnNewSpacePromotion); 4397 instr->SetDependsOnFlag(::v8::internal::kNewSpacePromotion);
4398 instr->SetFlag(HValue::kTrackSideEffectDominators); 4398 instr->SetFlag(HValue::kTrackSideEffectDominators);
4399 } else { 4399 } else {
4400 // try to GVN loads, but don't hoist above map changes 4400 // try to GVN loads, but don't hoist above map changes
4401 instr->SetFlag(HValue::kUseGVN); 4401 instr->SetFlag(HValue::kUseGVN);
4402 instr->SetGVNFlag(kDependsOnMaps); 4402 instr->SetDependsOnFlag(::v8::internal::kMaps);
4403 } 4403 }
4404 4404
4405 switch (portion()) { 4405 switch (portion()) {
4406 case kArrayLengths: 4406 case kArrayLengths:
4407 instr->SetGVNFlag(access_type == STORE 4407 if (access_type == STORE) {
4408 ? kChangesArrayLengths : kDependsOnArrayLengths); 4408 instr->SetChangesFlag(::v8::internal::kArrayLengths);
4409 } else {
4410 instr->SetDependsOnFlag(::v8::internal::kArrayLengths);
4411 }
4409 break; 4412 break;
4410 case kStringLengths: 4413 case kStringLengths:
4411 instr->SetGVNFlag(access_type == STORE 4414 if (access_type == STORE) {
4412 ? kChangesStringLengths : kDependsOnStringLengths); 4415 instr->SetChangesFlag(::v8::internal::kStringLengths);
4416 } else {
4417 instr->SetDependsOnFlag(::v8::internal::kStringLengths);
4418 }
4413 break; 4419 break;
4414 case kInobject: 4420 case kInobject:
4415 instr->SetGVNFlag(access_type == STORE 4421 if (access_type == STORE) {
4416 ? kChangesInobjectFields : kDependsOnInobjectFields); 4422 instr->SetChangesFlag(::v8::internal::kInobjectFields);
4423 } else {
4424 instr->SetDependsOnFlag(::v8::internal::kInobjectFields);
4425 }
4417 break; 4426 break;
4418 case kDouble: 4427 case kDouble:
4419 instr->SetGVNFlag(access_type == STORE 4428 if (access_type == STORE) {
4420 ? kChangesDoubleFields : kDependsOnDoubleFields); 4429 instr->SetChangesFlag(::v8::internal::kDoubleFields);
4430 } else {
4431 instr->SetDependsOnFlag(::v8::internal::kDoubleFields);
4432 }
4421 break; 4433 break;
4422 case kBackingStore: 4434 case kBackingStore:
4423 instr->SetGVNFlag(access_type == STORE 4435 if (access_type == STORE) {
4424 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); 4436 instr->SetChangesFlag(::v8::internal::kBackingStoreFields);
4437 } else {
4438 instr->SetDependsOnFlag(::v8::internal::kBackingStoreFields);
4439 }
4425 break; 4440 break;
4426 case kElementsPointer: 4441 case kElementsPointer:
4427 instr->SetGVNFlag(access_type == STORE 4442 if (access_type == STORE) {
4428 ? kChangesElementsPointer : kDependsOnElementsPointer); 4443 instr->SetChangesFlag(::v8::internal::kElementsPointer);
4444 } else {
4445 instr->SetDependsOnFlag(::v8::internal::kElementsPointer);
4446 }
4429 break; 4447 break;
4430 case kMaps: 4448 case kMaps:
4431 instr->SetGVNFlag(access_type == STORE 4449 if (access_type == STORE) {
4432 ? kChangesMaps : kDependsOnMaps); 4450 instr->SetChangesFlag(::v8::internal::kMaps);
4451 } else {
4452 instr->SetDependsOnFlag(::v8::internal::kMaps);
4453 }
4433 break; 4454 break;
4434 case kExternalMemory: 4455 case kExternalMemory:
4435 instr->SetGVNFlag(access_type == STORE 4456 if (access_type == STORE) {
4436 ? kChangesExternalMemory : kDependsOnExternalMemory); 4457 instr->SetChangesFlag(::v8::internal::kExternalMemory);
4458 } else {
4459 instr->SetDependsOnFlag(::v8::internal::kExternalMemory);
4460 }
4437 break; 4461 break;
4438 } 4462 }
4439 } 4463 }
4440 4464
4441 4465
4442 void HObjectAccess::PrintTo(StringStream* stream) { 4466 void HObjectAccess::PrintTo(StringStream* stream) const {
4443 stream->Add("."); 4467 stream->Add(".");
4444 4468
4445 switch (portion()) { 4469 switch (portion()) {
4446 case kArrayLengths: 4470 case kArrayLengths:
4447 case kStringLengths: 4471 case kStringLengths:
4448 stream->Add("%length"); 4472 stream->Add("%length");
4449 break; 4473 break;
4450 case kElementsPointer: 4474 case kElementsPointer:
4451 stream->Add("%elements"); 4475 stream->Add("%elements");
4452 break; 4476 break;
(...skipping 15 matching lines...) Expand all
4468 break; 4492 break;
4469 case kExternalMemory: 4493 case kExternalMemory:
4470 stream->Add("[external-memory]"); 4494 stream->Add("[external-memory]");
4471 break; 4495 break;
4472 } 4496 }
4473 4497
4474 stream->Add("@%d", offset()); 4498 stream->Add("@%d", offset());
4475 } 4499 }
4476 4500
4477 } } // namespace v8::internal 4501 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/hydrogen-load-elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698