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

Side by Side Diff: src/hydrogen.cc

Issue 16871011: Reduce usage of AssumeRepresentation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 merge_block_(NULL) { 702 merge_block_(NULL) {
703 continuation->Continue(&first_true_block_, 703 continuation->Continue(&first_true_block_,
704 &first_false_block_, 704 &first_false_block_,
705 &position_); 705 &position_);
706 } 706 }
707 707
708 708
709 HInstruction* HGraphBuilder::IfBuilder::IfCompare( 709 HInstruction* HGraphBuilder::IfBuilder::IfCompare(
710 HValue* left, 710 HValue* left,
711 HValue* right, 711 HValue* right,
712 Token::Value token, 712 Token::Value token) {
713 Representation input_representation) {
714 HCompareIDAndBranch* compare = 713 HCompareIDAndBranch* compare =
715 new(zone()) HCompareIDAndBranch(left, right, token); 714 new(zone()) HCompareIDAndBranch(left, right, token);
716 compare->set_observed_input_representation(input_representation,
717 input_representation);
718 compare->AssumeRepresentation(input_representation);
719 AddCompare(compare); 715 AddCompare(compare);
720 return compare; 716 return compare;
721 } 717 }
722 718
723 719
724 HInstruction* HGraphBuilder::IfBuilder::IfCompareMap(HValue* left, 720 HInstruction* HGraphBuilder::IfBuilder::IfCompareMap(HValue* left,
725 Handle<Map> map) { 721 Handle<Map> map) {
726 HCompareMap* compare = 722 HCompareMap* compare =
727 new(zone()) HCompareMap(left, map, first_true_block_, first_false_block_); 723 new(zone()) HCompareMap(left, map, first_true_block_, first_false_block_);
728 AddCompare(compare); 724 AddCompare(compare);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1158
1163 environment()->Push(new_elements); 1159 environment()->Push(new_elements);
1164 capacity_checker.Else(); 1160 capacity_checker.Else();
1165 1161
1166 environment()->Push(elements); 1162 environment()->Push(elements);
1167 capacity_checker.End(); 1163 capacity_checker.End();
1168 1164
1169 if (is_js_array) { 1165 if (is_js_array) {
1170 HValue* new_length = AddInstruction( 1166 HValue* new_length = AddInstruction(
1171 HAdd::New(zone, context, length, graph_->GetConstant1())); 1167 HAdd::New(zone, context, length, graph_->GetConstant1()));
1172 new_length->AssumeRepresentation(Representation::Integer32());
1173 new_length->ClearFlag(HValue::kCanOverflow); 1168 new_length->ClearFlag(HValue::kCanOverflow);
1174 1169
1175 Representation representation = IsFastElementsKind(kind) 1170 Representation representation = IsFastElementsKind(kind)
1176 ? Representation::Smi() : Representation::Tagged(); 1171 ? Representation::Smi() : Representation::Tagged();
1177 AddStore(object, HObjectAccess::ForArrayLength(), new_length, 1172 AddStore(object, HObjectAccess::ForArrayLength(), new_length,
1178 representation); 1173 representation);
1179 } 1174 }
1180 1175
1181 length_checker.Else(); 1176 length_checker.Else();
1182 1177
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 ElementsKind kind, 1334 ElementsKind kind,
1340 HValue* capacity) { 1335 HValue* capacity) {
1341 Zone* zone = this->zone(); 1336 Zone* zone = this->zone();
1342 1337
1343 int elements_size = IsFastDoubleElementsKind(kind) 1338 int elements_size = IsFastDoubleElementsKind(kind)
1344 ? kDoubleSize : kPointerSize; 1339 ? kDoubleSize : kPointerSize;
1345 HConstant* elements_size_value = new(zone) HConstant(elements_size); 1340 HConstant* elements_size_value = new(zone) HConstant(elements_size);
1346 AddInstruction(elements_size_value); 1341 AddInstruction(elements_size_value);
1347 HValue* mul = AddInstruction( 1342 HValue* mul = AddInstruction(
1348 HMul::New(zone, context, capacity, elements_size_value)); 1343 HMul::New(zone, context, capacity, elements_size_value));
1349 mul->AssumeRepresentation(Representation::Integer32());
1350 mul->ClearFlag(HValue::kCanOverflow); 1344 mul->ClearFlag(HValue::kCanOverflow);
1351 1345
1352 HConstant* header_size = new(zone) HConstant(FixedArray::kHeaderSize); 1346 HConstant* header_size = new(zone) HConstant(FixedArray::kHeaderSize);
1353 AddInstruction(header_size); 1347 AddInstruction(header_size);
1354 HValue* total_size = AddInstruction( 1348 HValue* total_size = AddInstruction(
1355 HAdd::New(zone, context, mul, header_size)); 1349 HAdd::New(zone, context, mul, header_size));
1356 total_size->AssumeRepresentation(Representation::Integer32());
1357 total_size->ClearFlag(HValue::kCanOverflow); 1350 total_size->ClearFlag(HValue::kCanOverflow);
1358 1351
1359 HAllocate::Flags flags = HAllocate::DefaultFlags(kind); 1352 HAllocate::Flags flags = HAllocate::DefaultFlags(kind);
1360 if (isolate()->heap()->ShouldGloballyPretenure()) { 1353 if (isolate()->heap()->ShouldGloballyPretenure()) {
1361 // TODO(hpayer): When pretenuring can be internalized, flags can become 1354 // TODO(hpayer): When pretenuring can be internalized, flags can become
1362 // private to HAllocate. 1355 // private to HAllocate.
1363 if (IsFastDoubleElementsKind(kind)) { 1356 if (IsFastDoubleElementsKind(kind)) {
1364 flags = static_cast<HAllocate::Flags>( 1357 flags = static_cast<HAllocate::Flags>(
1365 flags | HAllocate::CAN_ALLOCATE_IN_OLD_DATA_SPACE); 1358 flags | HAllocate::CAN_ALLOCATE_IN_OLD_DATA_SPACE);
1366 } else { 1359 } else {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck); 1436 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck);
1444 } 1437 }
1445 1438
1446 1439
1447 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, 1440 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context,
1448 HValue* old_capacity) { 1441 HValue* old_capacity) {
1449 Zone* zone = this->zone(); 1442 Zone* zone = this->zone();
1450 HValue* half_old_capacity = 1443 HValue* half_old_capacity =
1451 AddInstruction(HShr::New(zone, context, old_capacity, 1444 AddInstruction(HShr::New(zone, context, old_capacity,
1452 graph_->GetConstant1())); 1445 graph_->GetConstant1()));
1453 half_old_capacity->AssumeRepresentation(Representation::Integer32());
1454 half_old_capacity->ClearFlag(HValue::kCanOverflow); 1446 half_old_capacity->ClearFlag(HValue::kCanOverflow);
1455 1447
1456 HValue* new_capacity = AddInstruction( 1448 HValue* new_capacity = AddInstruction(
1457 HAdd::New(zone, context, half_old_capacity, old_capacity)); 1449 HAdd::New(zone, context, half_old_capacity, old_capacity));
1458 new_capacity->AssumeRepresentation(Representation::Integer32());
1459 new_capacity->ClearFlag(HValue::kCanOverflow); 1450 new_capacity->ClearFlag(HValue::kCanOverflow);
1460 1451
1461 HValue* min_growth = AddInstruction(new(zone) HConstant(16)); 1452 HValue* min_growth = AddInstruction(new(zone) HConstant(16));
1462 1453
1463 new_capacity = AddInstruction( 1454 new_capacity = AddInstruction(
1464 HAdd::New(zone, context, new_capacity, min_growth)); 1455 HAdd::New(zone, context, new_capacity, min_growth));
1465 new_capacity->AssumeRepresentation(Representation::Integer32());
1466 new_capacity->ClearFlag(HValue::kCanOverflow); 1456 new_capacity->ClearFlag(HValue::kCanOverflow);
1467 1457
1468 return new_capacity; 1458 return new_capacity;
1469 } 1459 }
1470 1460
1471 1461
1472 void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind kind) { 1462 void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind kind) {
1473 Zone* zone = this->zone(); 1463 Zone* zone = this->zone();
1474 Heap* heap = isolate()->heap(); 1464 Heap* heap = isolate()->heap();
1475 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize 1465 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 if (IsFastDoubleElementsKind(kind_)) { 1817 if (IsFastDoubleElementsKind(kind_)) {
1828 base_size += FixedDoubleArray::kHeaderSize; 1818 base_size += FixedDoubleArray::kHeaderSize;
1829 } else { 1819 } else {
1830 base_size += FixedArray::kHeaderSize; 1820 base_size += FixedArray::kHeaderSize;
1831 } 1821 }
1832 1822
1833 HInstruction* elements_size_value = new(zone()) HConstant(elements_size()); 1823 HInstruction* elements_size_value = new(zone()) HConstant(elements_size());
1834 AddInstruction(elements_size_value); 1824 AddInstruction(elements_size_value);
1835 HInstruction* mul = HMul::New(zone(), context, length_node, 1825 HInstruction* mul = HMul::New(zone(), context, length_node,
1836 elements_size_value); 1826 elements_size_value);
1837 mul->AssumeRepresentation(Representation::Integer32());
1838 mul->ClearFlag(HValue::kCanOverflow); 1827 mul->ClearFlag(HValue::kCanOverflow);
1839 AddInstruction(mul); 1828 AddInstruction(mul);
1840 1829
1841 HInstruction* base = new(zone()) HConstant(base_size); 1830 HInstruction* base = new(zone()) HConstant(base_size);
1842 AddInstruction(base); 1831 AddInstruction(base);
1843 HInstruction* total_size = HAdd::New(zone(), context, base, mul); 1832 HInstruction* total_size = HAdd::New(zone(), context, base, mul);
1844 total_size->AssumeRepresentation(Representation::Integer32());
1845 total_size->ClearFlag(HValue::kCanOverflow); 1833 total_size->ClearFlag(HValue::kCanOverflow);
1846 AddInstruction(total_size); 1834 AddInstruction(total_size);
1847 return total_size; 1835 return total_size;
1848 } 1836 }
1849 1837
1850 1838
1851 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { 1839 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() {
1852 int base_size = JSArray::kSize; 1840 int base_size = JSArray::kSize;
1853 if (mode_ == TRACK_ALLOCATION_SITE) { 1841 if (mode_ == TRACK_ALLOCATION_SITE) {
1854 base_size += AllocationSiteInfo::kSize; 1842 base_size += AllocationSiteInfo::kSize;
(...skipping 9728 matching lines...) Expand 10 before | Expand all | Expand 10 after
11583 } 11571 }
11584 } 11572 }
11585 11573
11586 #ifdef DEBUG 11574 #ifdef DEBUG
11587 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11575 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11588 if (allocator_ != NULL) allocator_->Verify(); 11576 if (allocator_ != NULL) allocator_->Verify();
11589 #endif 11577 #endif
11590 } 11578 }
11591 11579
11592 } } // namespace v8::internal 11580 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698