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

Side by Side Diff: src/hydrogen.cc

Issue 17162002: Version 3.19.17. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
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') | src/hydrogen-instructions.h » ('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 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) {
713 HCompareIDAndBranch* compare = 714 HCompareIDAndBranch* compare =
714 new(zone()) HCompareIDAndBranch(left, right, token); 715 new(zone()) HCompareIDAndBranch(left, right, token);
716 compare->set_observed_input_representation(input_representation,
717 input_representation);
718 compare->AssumeRepresentation(input_representation);
715 AddCompare(compare); 719 AddCompare(compare);
716 return compare; 720 return compare;
717 } 721 }
718 722
719 723
720 HInstruction* HGraphBuilder::IfBuilder::IfCompareMap(HValue* left, 724 HInstruction* HGraphBuilder::IfBuilder::IfCompareMap(HValue* left,
721 Handle<Map> map) { 725 Handle<Map> map) {
722 HCompareMap* compare = 726 HCompareMap* compare =
723 new(zone()) HCompareMap(left, map, first_true_block_, first_false_block_); 727 new(zone()) HCompareMap(left, map, first_true_block_, first_false_block_);
724 AddCompare(compare); 728 AddCompare(compare);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length); 997 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length);
994 AddInstruction(result); 998 AddInstruction(result);
995 return result; 999 return result;
996 } 1000 }
997 1001
998 1002
999 HReturn* HGraphBuilder::AddReturn(HValue* value) { 1003 HReturn* HGraphBuilder::AddReturn(HValue* value) {
1000 HValue* context = environment()->LookupContext(); 1004 HValue* context = environment()->LookupContext();
1001 int num_parameters = graph()->info()->num_parameters(); 1005 int num_parameters = graph()->info()->num_parameters();
1002 HValue* params = AddInstruction(new(graph()->zone()) 1006 HValue* params = AddInstruction(new(graph()->zone())
1003 HConstant(num_parameters)); 1007 HConstant(num_parameters, Representation::Integer32()));
1004 HReturn* return_instruction = new(graph()->zone()) 1008 HReturn* return_instruction = new(graph()->zone())
1005 HReturn(value, context, params); 1009 HReturn(value, context, params);
1006 current_block()->FinishExit(return_instruction); 1010 current_block()->FinishExit(return_instruction);
1007 return return_instruction; 1011 return return_instruction;
1008 } 1012 }
1009 1013
1010 1014
1011 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { 1015 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) {
1012 HBasicBlock* b = graph()->CreateBasicBlock(); 1016 HBasicBlock* b = graph()->CreateBasicBlock();
1013 b->SetInitialEnvironment(env); 1017 b->SetInitialEnvironment(env);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1162
1159 environment()->Push(new_elements); 1163 environment()->Push(new_elements);
1160 capacity_checker.Else(); 1164 capacity_checker.Else();
1161 1165
1162 environment()->Push(elements); 1166 environment()->Push(elements);
1163 capacity_checker.End(); 1167 capacity_checker.End();
1164 1168
1165 if (is_js_array) { 1169 if (is_js_array) {
1166 HValue* new_length = AddInstruction( 1170 HValue* new_length = AddInstruction(
1167 HAdd::New(zone, context, length, graph_->GetConstant1())); 1171 HAdd::New(zone, context, length, graph_->GetConstant1()));
1172 new_length->AssumeRepresentation(Representation::Integer32());
1168 new_length->ClearFlag(HValue::kCanOverflow); 1173 new_length->ClearFlag(HValue::kCanOverflow);
1169 1174
1170 Representation representation = IsFastElementsKind(kind) 1175 Representation representation = IsFastElementsKind(kind)
1171 ? Representation::Smi() : Representation::Tagged(); 1176 ? Representation::Smi() : Representation::Tagged();
1172 AddStore(object, HObjectAccess::ForArrayLength(), new_length, 1177 AddStore(object, HObjectAccess::ForArrayLength(), new_length,
1173 representation); 1178 representation);
1174 } 1179 }
1175 1180
1176 length_checker.Else(); 1181 length_checker.Else();
1177 1182
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 } 1335 }
1331 1336
1332 1337
1333 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, 1338 HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
1334 ElementsKind kind, 1339 ElementsKind kind,
1335 HValue* capacity) { 1340 HValue* capacity) {
1336 Zone* zone = this->zone(); 1341 Zone* zone = this->zone();
1337 1342
1338 int elements_size = IsFastDoubleElementsKind(kind) 1343 int elements_size = IsFastDoubleElementsKind(kind)
1339 ? kDoubleSize : kPointerSize; 1344 ? kDoubleSize : kPointerSize;
1340 HConstant* elements_size_value = new(zone) HConstant(elements_size); 1345 HConstant* elements_size_value =
1346 new(zone) HConstant(elements_size, Representation::Integer32());
1341 AddInstruction(elements_size_value); 1347 AddInstruction(elements_size_value);
1342 HValue* mul = AddInstruction( 1348 HValue* mul = AddInstruction(
1343 HMul::New(zone, context, capacity, elements_size_value)); 1349 HMul::New(zone, context, capacity, elements_size_value));
1350 mul->AssumeRepresentation(Representation::Integer32());
1344 mul->ClearFlag(HValue::kCanOverflow); 1351 mul->ClearFlag(HValue::kCanOverflow);
1345 1352
1346 HConstant* header_size = new(zone) HConstant(FixedArray::kHeaderSize); 1353 HConstant* header_size =
1354 new(zone) HConstant(FixedArray::kHeaderSize, Representation::Integer32());
1347 AddInstruction(header_size); 1355 AddInstruction(header_size);
1348 HValue* total_size = AddInstruction( 1356 HValue* total_size = AddInstruction(
1349 HAdd::New(zone, context, mul, header_size)); 1357 HAdd::New(zone, context, mul, header_size));
1358 total_size->AssumeRepresentation(Representation::Integer32());
1350 total_size->ClearFlag(HValue::kCanOverflow); 1359 total_size->ClearFlag(HValue::kCanOverflow);
1351 1360
1352 HAllocate::Flags flags = HAllocate::DefaultFlags(kind); 1361 HAllocate::Flags flags = HAllocate::DefaultFlags(kind);
1353 if (isolate()->heap()->ShouldGloballyPretenure()) { 1362 if (isolate()->heap()->ShouldGloballyPretenure()) {
1354 // TODO(hpayer): When pretenuring can be internalized, flags can become 1363 // TODO(hpayer): When pretenuring can be internalized, flags can become
1355 // private to HAllocate. 1364 // private to HAllocate.
1356 if (IsFastDoubleElementsKind(kind)) { 1365 if (IsFastDoubleElementsKind(kind)) {
1357 flags = static_cast<HAllocate::Flags>( 1366 flags = static_cast<HAllocate::Flags>(
1358 flags | HAllocate::CAN_ALLOCATE_IN_OLD_DATA_SPACE); 1367 flags | HAllocate::CAN_ALLOCATE_IN_OLD_DATA_SPACE);
1359 } else { 1368 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 1406
1398 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, 1407 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
1399 HValue* array_map, 1408 HValue* array_map,
1400 AllocationSiteMode mode, 1409 AllocationSiteMode mode,
1401 HValue* allocation_site_payload, 1410 HValue* allocation_site_payload,
1402 HValue* length_field) { 1411 HValue* length_field) {
1403 1412
1404 AddStore(array, HObjectAccess::ForMap(), array_map); 1413 AddStore(array, HObjectAccess::ForMap(), array_map);
1405 1414
1406 HConstant* empty_fixed_array = 1415 HConstant* empty_fixed_array =
1407 new(zone()) HConstant(isolate()->factory()->empty_fixed_array()); 1416 new(zone()) HConstant(
1417 Handle<FixedArray>(isolate()->heap()->empty_fixed_array()),
1418 Representation::Tagged());
1408 AddInstruction(empty_fixed_array); 1419 AddInstruction(empty_fixed_array);
1409 1420
1410 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 1421 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
1411 AddStore(array, access, empty_fixed_array); 1422 AddStore(array, access, empty_fixed_array);
1412 AddStore(array, HObjectAccess::ForArrayLength(), length_field); 1423 AddStore(array, HObjectAccess::ForArrayLength(), length_field);
1413 1424
1414 if (mode == TRACK_ALLOCATION_SITE) { 1425 if (mode == TRACK_ALLOCATION_SITE) {
1415 BuildCreateAllocationSiteInfo(array, 1426 BuildCreateAllocationSiteInfo(array,
1416 JSArray::kSize, 1427 JSArray::kSize,
1417 allocation_site_payload); 1428 allocation_site_payload);
(...skipping 18 matching lines...) Expand all
1436 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck); 1447 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck);
1437 } 1448 }
1438 1449
1439 1450
1440 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, 1451 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context,
1441 HValue* old_capacity) { 1452 HValue* old_capacity) {
1442 Zone* zone = this->zone(); 1453 Zone* zone = this->zone();
1443 HValue* half_old_capacity = 1454 HValue* half_old_capacity =
1444 AddInstruction(HShr::New(zone, context, old_capacity, 1455 AddInstruction(HShr::New(zone, context, old_capacity,
1445 graph_->GetConstant1())); 1456 graph_->GetConstant1()));
1457 half_old_capacity->AssumeRepresentation(Representation::Integer32());
1446 half_old_capacity->ClearFlag(HValue::kCanOverflow); 1458 half_old_capacity->ClearFlag(HValue::kCanOverflow);
1447 1459
1448 HValue* new_capacity = AddInstruction( 1460 HValue* new_capacity = AddInstruction(
1449 HAdd::New(zone, context, half_old_capacity, old_capacity)); 1461 HAdd::New(zone, context, half_old_capacity, old_capacity));
1462 new_capacity->AssumeRepresentation(Representation::Integer32());
1450 new_capacity->ClearFlag(HValue::kCanOverflow); 1463 new_capacity->ClearFlag(HValue::kCanOverflow);
1451 1464
1452 HValue* min_growth = AddInstruction(new(zone) HConstant(16)); 1465 HValue* min_growth =
1466 AddInstruction(new(zone) HConstant(16, Representation::Integer32()));
1453 1467
1454 new_capacity = AddInstruction( 1468 new_capacity = AddInstruction(
1455 HAdd::New(zone, context, new_capacity, min_growth)); 1469 HAdd::New(zone, context, new_capacity, min_growth));
1470 new_capacity->AssumeRepresentation(Representation::Integer32());
1456 new_capacity->ClearFlag(HValue::kCanOverflow); 1471 new_capacity->ClearFlag(HValue::kCanOverflow);
1457 1472
1458 return new_capacity; 1473 return new_capacity;
1459 } 1474 }
1460 1475
1461 1476
1462 void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind kind) { 1477 void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind kind) {
1463 Zone* zone = this->zone(); 1478 Zone* zone = this->zone();
1464 Heap* heap = isolate()->heap(); 1479 Heap* heap = isolate()->heap();
1465 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize 1480 int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 ElementsKind elements_kind, 1516 ElementsKind elements_kind,
1502 HValue* from, 1517 HValue* from,
1503 HValue* to) { 1518 HValue* to) {
1504 // Fast elements kinds need to be initialized in case statements below cause 1519 // Fast elements kinds need to be initialized in case statements below cause
1505 // a garbage collection. 1520 // a garbage collection.
1506 Factory* factory = isolate()->factory(); 1521 Factory* factory = isolate()->factory();
1507 1522
1508 double nan_double = FixedDoubleArray::hole_nan_as_double(); 1523 double nan_double = FixedDoubleArray::hole_nan_as_double();
1509 Zone* zone = this->zone(); 1524 Zone* zone = this->zone();
1510 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) 1525 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind)
1511 ? AddInstruction(new(zone) HConstant(factory->the_hole_value())) 1526 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(),
1512 : AddInstruction(new(zone) HConstant(nan_double)); 1527 Representation::Tagged()))
1528 : AddInstruction(new(zone) HConstant(nan_double,
1529 Representation::Double()));
1513 1530
1514 // Special loop unfolding case 1531 // Special loop unfolding case
1515 static const int kLoopUnfoldLimit = 4; 1532 static const int kLoopUnfoldLimit = 4;
1516 bool unfold_loop = false; 1533 bool unfold_loop = false;
1517 int initial_capacity = JSArray::kPreallocatedArrayElements; 1534 int initial_capacity = JSArray::kPreallocatedArrayElements;
1518 if (from->IsConstant() && to->IsConstant() && 1535 if (from->IsConstant() && to->IsConstant() &&
1519 initial_capacity <= kLoopUnfoldLimit) { 1536 initial_capacity <= kLoopUnfoldLimit) {
1520 HConstant* constant_from = HConstant::cast(from); 1537 HConstant* constant_from = HConstant::cast(from);
1521 HConstant* constant_to = HConstant::cast(to); 1538 HConstant* constant_to = HConstant::cast(to);
1522 1539
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 int elems_offset = size; 1632 int elems_offset = size;
1616 if (length > 0) { 1633 if (length > 0) {
1617 size += IsFastDoubleElementsKind(kind) 1634 size += IsFastDoubleElementsKind(kind)
1618 ? FixedDoubleArray::SizeFor(length) 1635 ? FixedDoubleArray::SizeFor(length)
1619 : FixedArray::SizeFor(length); 1636 : FixedArray::SizeFor(length);
1620 } 1637 }
1621 1638
1622 HAllocate::Flags allocate_flags = HAllocate::DefaultFlags(kind); 1639 HAllocate::Flags allocate_flags = HAllocate::DefaultFlags(kind);
1623 // Allocate both the JS array and the elements array in one big 1640 // Allocate both the JS array and the elements array in one big
1624 // allocation. This avoids multiple limit checks. 1641 // allocation. This avoids multiple limit checks.
1625 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); 1642 HValue* size_in_bytes =
1643 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
1626 HInstruction* object = 1644 HInstruction* object =
1627 AddInstruction(new(zone) HAllocate(context, 1645 AddInstruction(new(zone) HAllocate(context,
1628 size_in_bytes, 1646 size_in_bytes,
1629 HType::JSObject(), 1647 HType::JSObject(),
1630 allocate_flags)); 1648 allocate_flags));
1631 1649
1632 // Copy the JS array part. 1650 // Copy the JS array part.
1633 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 1651 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
1634 if ((i != JSArray::kElementsOffset) || (length == 0)) { 1652 if ((i != JSArray::kElementsOffset) || (length == 0)) {
1635 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); 1653 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 HGlobalObject(context)); 1756 HGlobalObject(context));
1739 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 1757 HObjectAccess access = HObjectAccess::ForJSObjectOffset(
1740 GlobalObject::kNativeContextOffset); 1758 GlobalObject::kNativeContextOffset);
1741 return AddLoad(global_object, access); 1759 return AddLoad(global_object, access);
1742 } 1760 }
1743 1761
1744 1762
1745 HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) { 1763 HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) {
1746 HInstruction* native_context = BuildGetNativeContext(context); 1764 HInstruction* native_context = BuildGetNativeContext(context);
1747 HInstruction* index = AddInstruction(new(zone()) 1765 HInstruction* index = AddInstruction(new(zone())
1748 HConstant(Context::ARRAY_FUNCTION_INDEX)); 1766 HConstant(Context::ARRAY_FUNCTION_INDEX, Representation::Integer32()));
1749 1767
1750 return AddInstruction(new (zone()) 1768 return AddInstruction(new (zone())
1751 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); 1769 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS));
1752 } 1770 }
1753 1771
1754 1772
1755 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, 1773 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
1756 ElementsKind kind, 1774 ElementsKind kind,
1757 HValue* allocation_site_payload, 1775 HValue* allocation_site_payload,
1758 bool disable_allocation_sites) : 1776 bool disable_allocation_sites) :
(...skipping 15 matching lines...) Expand all
1774 mode_(DONT_TRACK_ALLOCATION_SITE), 1792 mode_(DONT_TRACK_ALLOCATION_SITE),
1775 allocation_site_payload_(NULL), 1793 allocation_site_payload_(NULL),
1776 constructor_function_(constructor_function) { 1794 constructor_function_(constructor_function) {
1777 } 1795 }
1778 1796
1779 1797
1780 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { 1798 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) {
1781 HInstruction* native_context = builder()->BuildGetNativeContext(context); 1799 HInstruction* native_context = builder()->BuildGetNativeContext(context);
1782 1800
1783 HInstruction* index = builder()->AddInstruction(new(zone()) 1801 HInstruction* index = builder()->AddInstruction(new(zone())
1784 HConstant(Context::JS_ARRAY_MAPS_INDEX)); 1802 HConstant(Context::JS_ARRAY_MAPS_INDEX, Representation::Integer32()));
1785 1803
1786 HInstruction* map_array = builder()->AddInstruction(new(zone()) 1804 HInstruction* map_array = builder()->AddInstruction(new(zone())
1787 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); 1805 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS));
1788 1806
1789 HInstruction* kind_index = builder()->AddInstruction(new(zone()) 1807 HInstruction* kind_index = builder()->AddInstruction(new(zone())
1790 HConstant(kind_)); 1808 HConstant(kind_, Representation::Integer32()));
1791 1809
1792 return builder()->AddInstruction(new(zone()) 1810 return builder()->AddInstruction(new(zone())
1793 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); 1811 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS));
1794 } 1812 }
1795 1813
1796 1814
1797 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { 1815 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() {
1798 // Find the map near the constructor function 1816 // Find the map near the constructor function
1799 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); 1817 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
1800 return AddInstruction( 1818 return AddInstruction(
(...skipping 12 matching lines...) Expand all
1813 if (mode_ == TRACK_ALLOCATION_SITE) { 1831 if (mode_ == TRACK_ALLOCATION_SITE) {
1814 base_size += AllocationSiteInfo::kSize; 1832 base_size += AllocationSiteInfo::kSize;
1815 } 1833 }
1816 1834
1817 if (IsFastDoubleElementsKind(kind_)) { 1835 if (IsFastDoubleElementsKind(kind_)) {
1818 base_size += FixedDoubleArray::kHeaderSize; 1836 base_size += FixedDoubleArray::kHeaderSize;
1819 } else { 1837 } else {
1820 base_size += FixedArray::kHeaderSize; 1838 base_size += FixedArray::kHeaderSize;
1821 } 1839 }
1822 1840
1823 HInstruction* elements_size_value = new(zone()) HConstant(elements_size()); 1841 HInstruction* elements_size_value = new(zone())
1842 HConstant(elements_size(), Representation::Integer32());
1824 AddInstruction(elements_size_value); 1843 AddInstruction(elements_size_value);
1825 HInstruction* mul = HMul::New(zone(), context, length_node, 1844 HInstruction* mul = HMul::New(zone(), context, length_node,
1826 elements_size_value); 1845 elements_size_value);
1846 mul->AssumeRepresentation(Representation::Integer32());
1827 mul->ClearFlag(HValue::kCanOverflow); 1847 mul->ClearFlag(HValue::kCanOverflow);
1828 AddInstruction(mul); 1848 AddInstruction(mul);
1829 1849
1830 HInstruction* base = new(zone()) HConstant(base_size); 1850 HInstruction* base = new(zone()) HConstant(base_size,
1851 Representation::Integer32());
1831 AddInstruction(base); 1852 AddInstruction(base);
1832 HInstruction* total_size = HAdd::New(zone(), context, base, mul); 1853 HInstruction* total_size = HAdd::New(zone(), context, base, mul);
1854 total_size->AssumeRepresentation(Representation::Integer32());
1833 total_size->ClearFlag(HValue::kCanOverflow); 1855 total_size->ClearFlag(HValue::kCanOverflow);
1834 AddInstruction(total_size); 1856 AddInstruction(total_size);
1835 return total_size; 1857 return total_size;
1836 } 1858 }
1837 1859
1838 1860
1839 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { 1861 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() {
1840 int base_size = JSArray::kSize; 1862 int base_size = JSArray::kSize;
1841 if (mode_ == TRACK_ALLOCATION_SITE) { 1863 if (mode_ == TRACK_ALLOCATION_SITE) {
1842 base_size += AllocationSiteInfo::kSize; 1864 base_size += AllocationSiteInfo::kSize;
1843 } 1865 }
1844 1866
1845 base_size += IsFastDoubleElementsKind(kind_) 1867 base_size += IsFastDoubleElementsKind(kind_)
1846 ? FixedDoubleArray::SizeFor(initial_capacity()) 1868 ? FixedDoubleArray::SizeFor(initial_capacity())
1847 : FixedArray::SizeFor(initial_capacity()); 1869 : FixedArray::SizeFor(initial_capacity());
1848 1870
1849 HConstant* array_size = new(zone()) HConstant(base_size); 1871 HConstant* array_size =
1872 new(zone()) HConstant(base_size, Representation::Integer32());
1850 AddInstruction(array_size); 1873 AddInstruction(array_size);
1851 return array_size; 1874 return array_size;
1852 } 1875 }
1853 1876
1854 1877
1855 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { 1878 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() {
1856 HValue* size_in_bytes = EstablishEmptyArrayAllocationSize(); 1879 HValue* size_in_bytes = EstablishEmptyArrayAllocationSize();
1857 HConstant* capacity = new(zone()) HConstant(initial_capacity()); 1880 HConstant* capacity =
1881 new(zone()) HConstant(initial_capacity(), Representation::Integer32());
1858 AddInstruction(capacity); 1882 AddInstruction(capacity);
1859 return AllocateArray(size_in_bytes, 1883 return AllocateArray(size_in_bytes,
1860 capacity, 1884 capacity,
1861 builder()->graph()->GetConstant0(), 1885 builder()->graph()->GetConstant0(),
1862 true); 1886 true);
1863 } 1887 }
1864 1888
1865 1889
1866 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity, 1890 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity,
1867 HValue* length_field, 1891 HValue* length_field,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 Representation representation) { 1949 Representation representation) {
1926 HLoadNamedField *instr = 1950 HLoadNamedField *instr =
1927 new(zone()) HLoadNamedField(object, access, typecheck, representation); 1951 new(zone()) HLoadNamedField(object, access, typecheck, representation);
1928 AddInstruction(instr); 1952 AddInstruction(instr);
1929 return instr; 1953 return instr;
1930 } 1954 }
1931 1955
1932 1956
1933 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, 1957 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
1934 Handle<Map> map) { 1958 Handle<Map> map) {
1935 HValue* constant = AddInstruction(new(zone()) HConstant(map)); 1959 HValue* constant =
1960 AddInstruction(new(zone()) HConstant(map, Representation::Tagged()));
1936 HStoreNamedField *instr = 1961 HStoreNamedField *instr =
1937 new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(), constant); 1962 new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(), constant);
1938 AddInstruction(instr); 1963 AddInstruction(instr);
1939 return instr; 1964 return instr;
1940 } 1965 }
1941 1966
1942 1967
1943 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) 1968 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
1944 : HGraphBuilder(info), 1969 : HGraphBuilder(info),
1945 function_state_(NULL), 1970 function_state_(NULL),
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 FunctionState::FunctionState(HOptimizedGraphBuilder* owner, 3539 FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
3515 CompilationInfo* info, 3540 CompilationInfo* info,
3516 InliningKind inlining_kind) 3541 InliningKind inlining_kind)
3517 : owner_(owner), 3542 : owner_(owner),
3518 compilation_info_(info), 3543 compilation_info_(info),
3519 call_context_(NULL), 3544 call_context_(NULL),
3520 inlining_kind_(inlining_kind), 3545 inlining_kind_(inlining_kind),
3521 function_return_(NULL), 3546 function_return_(NULL),
3522 test_context_(NULL), 3547 test_context_(NULL),
3523 entry_(NULL), 3548 entry_(NULL),
3524 arguments_object_(NULL),
3525 arguments_elements_(NULL), 3549 arguments_elements_(NULL),
3526 outer_(owner->function_state()) { 3550 outer_(owner->function_state()) {
3527 if (outer_ != NULL) { 3551 if (outer_ != NULL) {
3528 // State for an inline function. 3552 // State for an inline function.
3529 if (owner->ast_context()->IsTest()) { 3553 if (owner->ast_context()->IsTest()) {
3530 HBasicBlock* if_true = owner->graph()->CreateBasicBlock(); 3554 HBasicBlock* if_true = owner->graph()->CreateBasicBlock();
3531 HBasicBlock* if_false = owner->graph()->CreateBasicBlock(); 3555 HBasicBlock* if_false = owner->graph()->CreateBasicBlock();
3532 if_true->MarkAsInlineReturnTarget(owner->current_block()); 3556 if_true->MarkAsInlineReturnTarget(owner->current_block());
3533 if_false->MarkAsInlineReturnTarget(owner->current_block()); 3557 if_false->MarkAsInlineReturnTarget(owner->current_block());
3534 TestContext* outer_test_context = TestContext::cast(owner->ast_context()); 3558 TestContext* outer_test_context = TestContext::cast(owner->ast_context());
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 4686
4663 while (!arguments.is_empty()) { 4687 while (!arguments.is_empty()) {
4664 AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast())); 4688 AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast()));
4665 } 4689 }
4666 return call; 4690 return call;
4667 } 4691 }
4668 4692
4669 4693
4670 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) { 4694 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) {
4671 HConstant* undefined_constant = new(zone()) HConstant( 4695 HConstant* undefined_constant = new(zone()) HConstant(
4672 isolate()->factory()->undefined_value()); 4696 isolate()->factory()->undefined_value(), Representation::Tagged());
4673 AddInstruction(undefined_constant); 4697 AddInstruction(undefined_constant);
4674 graph()->set_undefined_constant(undefined_constant); 4698 graph()->set_undefined_constant(undefined_constant);
4675 4699
4676 // Create an arguments object containing the initial parameters. Set the 4700 HArgumentsObject* object = new(zone()) HArgumentsObject;
4677 // initial values of parameters including "this" having parameter index 0. 4701 AddInstruction(object);
4702 graph()->SetArgumentsObject(object);
4703
4704 // Set the initial values of parameters including "this". "This" has
4705 // parameter index 0.
4678 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); 4706 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count());
4679 HArgumentsObject* arguments_object = 4707
4680 new(zone()) HArgumentsObject(environment()->parameter_count(), zone());
4681 for (int i = 0; i < environment()->parameter_count(); ++i) { 4708 for (int i = 0; i < environment()->parameter_count(); ++i) {
4682 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i)); 4709 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i));
4683 arguments_object->AddArgument(parameter, zone());
4684 environment()->Bind(i, parameter); 4710 environment()->Bind(i, parameter);
4685 } 4711 }
4686 AddInstruction(arguments_object);
4687 graph()->SetArgumentsObject(arguments_object);
4688 4712
4689 // First special is HContext. 4713 // First special is HContext.
4690 HInstruction* context = AddInstruction(new(zone()) HContext); 4714 HInstruction* context = AddInstruction(new(zone()) HContext);
4691 environment()->BindContext(context); 4715 environment()->BindContext(context);
4692 4716
4693 // Initialize specials and locals to undefined. 4717 // Initialize specials and locals to undefined.
4694 for (int i = environment()->parameter_count() + 1; 4718 for (int i = environment()->parameter_count() + 1;
4695 i < environment()->length(); 4719 i < environment()->length();
4696 ++i) { 4720 ++i) {
4697 environment()->Bind(i, undefined_constant); 4721 environment()->Bind(i, undefined_constant);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
5001 if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) { 5025 if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) {
5002 if (!clause->compare_type()->Is(Type::Integer31())) { 5026 if (!clause->compare_type()->Is(Type::Integer31())) {
5003 AddSoftDeoptimize(); 5027 AddSoftDeoptimize();
5004 } 5028 }
5005 5029
5006 HCompareIDAndBranch* compare_ = 5030 HCompareIDAndBranch* compare_ =
5007 new(zone()) HCompareIDAndBranch(tag_value, 5031 new(zone()) HCompareIDAndBranch(tag_value,
5008 label_value, 5032 label_value,
5009 Token::EQ_STRICT); 5033 Token::EQ_STRICT);
5010 compare_->set_observed_input_representation( 5034 compare_->set_observed_input_representation(
5011 Representation::Smi(), Representation::Smi()); 5035 Representation::Integer32(), Representation::Integer32());
5012 compare = compare_; 5036 compare = compare_;
5013 } else { 5037 } else {
5014 compare = new(zone()) HStringCompareAndBranch(context, tag_value, 5038 compare = new(zone()) HStringCompareAndBranch(context, tag_value,
5015 label_value, 5039 label_value,
5016 Token::EQ_STRICT); 5040 Token::EQ_STRICT);
5017 } 5041 }
5018 5042
5019 compare->SetSuccessorAt(0, body_block); 5043 compare->SetSuccessorAt(0, body_block);
5020 compare->SetSuccessorAt(1, next_test_block); 5044 compare->SetSuccessorAt(1, next_test_block);
5021 current_block()->Finish(compare); 5045 current_block()->Finish(compare);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
5366 set_current_block(loop_entry); 5390 set_current_block(loop_entry);
5367 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); 5391 if (osr_entry) graph()->set_osr_loop_entry(loop_entry);
5368 5392
5369 HValue* index = environment()->ExpressionStackAt(0); 5393 HValue* index = environment()->ExpressionStackAt(0);
5370 HValue* limit = environment()->ExpressionStackAt(1); 5394 HValue* limit = environment()->ExpressionStackAt(1);
5371 5395
5372 // Check that we still have more keys. 5396 // Check that we still have more keys.
5373 HCompareIDAndBranch* compare_index = 5397 HCompareIDAndBranch* compare_index =
5374 new(zone()) HCompareIDAndBranch(index, limit, Token::LT); 5398 new(zone()) HCompareIDAndBranch(index, limit, Token::LT);
5375 compare_index->set_observed_input_representation( 5399 compare_index->set_observed_input_representation(
5376 Representation::Smi(), Representation::Smi()); 5400 Representation::Integer32(), Representation::Integer32());
5377 5401
5378 HBasicBlock* loop_body = graph()->CreateBasicBlock(); 5402 HBasicBlock* loop_body = graph()->CreateBasicBlock();
5379 HBasicBlock* loop_successor = graph()->CreateBasicBlock(); 5403 HBasicBlock* loop_successor = graph()->CreateBasicBlock();
5380 5404
5381 compare_index->SetSuccessorAt(0, loop_body); 5405 compare_index->SetSuccessorAt(0, loop_body);
5382 compare_index->SetSuccessorAt(1, loop_successor); 5406 compare_index->SetSuccessorAt(1, loop_successor);
5383 current_block()->Finish(compare_index); 5407 current_block()->Finish(compare_index);
5384 5408
5385 set_current_block(loop_successor); 5409 set_current_block(loop_successor);
5386 Drop(5); 5410 Drop(5);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 case Variable::UNALLOCATED: { 5612 case Variable::UNALLOCATED: {
5589 if (IsLexicalVariableMode(variable->mode())) { 5613 if (IsLexicalVariableMode(variable->mode())) {
5590 // TODO(rossberg): should this be an ASSERT? 5614 // TODO(rossberg): should this be an ASSERT?
5591 return Bailout("reference to global lexical variable"); 5615 return Bailout("reference to global lexical variable");
5592 } 5616 }
5593 // Handle known global constants like 'undefined' specially to avoid a 5617 // Handle known global constants like 'undefined' specially to avoid a
5594 // load from a global cell for them. 5618 // load from a global cell for them.
5595 Handle<Object> constant_value = 5619 Handle<Object> constant_value =
5596 isolate()->factory()->GlobalConstantFor(variable->name()); 5620 isolate()->factory()->GlobalConstantFor(variable->name());
5597 if (!constant_value.is_null()) { 5621 if (!constant_value.is_null()) {
5598 HConstant* instr = new(zone()) HConstant(constant_value); 5622 HConstant* instr =
5623 new(zone()) HConstant(constant_value, Representation::Tagged());
5599 return ast_context()->ReturnInstruction(instr, expr->id()); 5624 return ast_context()->ReturnInstruction(instr, expr->id());
5600 } 5625 }
5601 5626
5602 LookupResult lookup(isolate()); 5627 LookupResult lookup(isolate());
5603 GlobalPropertyAccess type = 5628 GlobalPropertyAccess type =
5604 LookupGlobalProperty(variable, &lookup, false); 5629 LookupGlobalProperty(variable, &lookup, false);
5605 5630
5606 if (type == kUseCell && 5631 if (type == kUseCell &&
5607 current_info()->global_object()->IsAccessCheckNeeded()) { 5632 current_info()->global_object()->IsAccessCheckNeeded()) {
5608 type = kUseGeneric; 5633 type = kUseGeneric;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 case Variable::LOOKUP: 5673 case Variable::LOOKUP:
5649 return Bailout("reference to a variable which requires dynamic lookup"); 5674 return Bailout("reference to a variable which requires dynamic lookup");
5650 } 5675 }
5651 } 5676 }
5652 5677
5653 5678
5654 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { 5679 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) {
5655 ASSERT(!HasStackOverflow()); 5680 ASSERT(!HasStackOverflow());
5656 ASSERT(current_block() != NULL); 5681 ASSERT(current_block() != NULL);
5657 ASSERT(current_block()->HasPredecessor()); 5682 ASSERT(current_block()->HasPredecessor());
5658 HConstant* instr = new(zone()) HConstant(expr->handle()); 5683 HConstant* instr =
5684 new(zone()) HConstant(expr->handle(), Representation::None());
5659 return ast_context()->ReturnInstruction(instr, expr->id()); 5685 return ast_context()->ReturnInstruction(instr, expr->id());
5660 } 5686 }
5661 5687
5662 5688
5663 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { 5689 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
5664 ASSERT(!HasStackOverflow()); 5690 ASSERT(!HasStackOverflow());
5665 ASSERT(current_block() != NULL); 5691 ASSERT(current_block() != NULL);
5666 ASSERT(current_block()->HasPredecessor()); 5692 ASSERT(current_block()->HasPredecessor());
5667 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); 5693 Handle<JSFunction> closure = function_state()->compilation_info()->closure();
5668 Handle<FixedArray> literals(closure->literals()); 5694 Handle<FixedArray> literals(closure->literals());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
5873 NoObservableSideEffectsScope no_effects(this); 5899 NoObservableSideEffectsScope no_effects(this);
5874 Handle<FixedArray> closure_literals(closure->literals(), isolate()); 5900 Handle<FixedArray> closure_literals(closure->literals(), isolate());
5875 Handle<FixedArray> constant_properties = expr->constant_properties(); 5901 Handle<FixedArray> constant_properties = expr->constant_properties();
5876 int literal_index = expr->literal_index(); 5902 int literal_index = expr->literal_index();
5877 int flags = expr->fast_elements() 5903 int flags = expr->fast_elements()
5878 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; 5904 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags;
5879 flags |= expr->has_function() 5905 flags |= expr->has_function()
5880 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; 5906 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
5881 5907
5882 AddInstruction(new(zone()) HPushArgument(AddInstruction( 5908 AddInstruction(new(zone()) HPushArgument(AddInstruction(
5883 new(zone()) HConstant(closure_literals)))); 5909 new(zone()) HConstant(closure_literals, Representation::Tagged()))));
5884 AddInstruction(new(zone()) HPushArgument(AddInstruction( 5910 AddInstruction(new(zone()) HPushArgument(AddInstruction(
5885 new(zone()) HConstant(literal_index)))); 5911 new(zone()) HConstant(literal_index, Representation::Tagged()))));
5886 AddInstruction(new(zone()) HPushArgument(AddInstruction( 5912 AddInstruction(new(zone()) HPushArgument(AddInstruction(
5887 new(zone()) HConstant(constant_properties)))); 5913 new(zone()) HConstant(constant_properties, Representation::Tagged()))));
5888 AddInstruction(new(zone()) HPushArgument(AddInstruction( 5914 AddInstruction(new(zone()) HPushArgument(AddInstruction(
5889 new(zone()) HConstant(flags)))); 5915 new(zone()) HConstant(flags, Representation::Tagged()))));
5890 5916
5891 Runtime::FunctionId function_id = 5917 Runtime::FunctionId function_id =
5892 (expr->depth() > 1 || expr->may_store_doubles()) 5918 (expr->depth() > 1 || expr->may_store_doubles())
5893 ? Runtime::kCreateObjectLiteral : Runtime::kCreateObjectLiteralShallow; 5919 ? Runtime::kCreateObjectLiteral : Runtime::kCreateObjectLiteralShallow;
5894 literal = AddInstruction( 5920 literal = AddInstruction(
5895 new(zone()) HCallRuntime(context, 5921 new(zone()) HCallRuntime(context,
5896 isolate()->factory()->empty_string(), 5922 isolate()->factory()->empty_string(),
5897 Runtime::FunctionForId(function_id), 5923 Runtime::FunctionForId(function_id),
5898 4)); 5924 4));
5899 } 5925 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6037 // TODO(mstarzinger): The following check and deopt is actually obsolete 6063 // TODO(mstarzinger): The following check and deopt is actually obsolete
6038 // but test cases for the tick processor fails because profile differs. 6064 // but test cases for the tick processor fails because profile differs.
6039 6065
6040 // Deopt if the array literal boilerplate ElementsKind is of a type 6066 // Deopt if the array literal boilerplate ElementsKind is of a type
6041 // different than the expected one. The check isn't necessary if the 6067 // different than the expected one. The check isn't necessary if the
6042 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND. 6068 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND.
6043 if (CanTransitionToMoreGeneralFastElementsKind( 6069 if (CanTransitionToMoreGeneralFastElementsKind(
6044 boilerplate_elements_kind, true)) { 6070 boilerplate_elements_kind, true)) {
6045 IfBuilder builder(this); 6071 IfBuilder builder(this);
6046 HValue* boilerplate = AddInstruction(new(zone()) 6072 HValue* boilerplate = AddInstruction(new(zone())
6047 HConstant(original_boilerplate_object)); 6073 HConstant(original_boilerplate_object, Representation::Tagged()));
6048 HValue* elements_kind = AddInstruction(new(zone()) 6074 HValue* elements_kind = AddInstruction(new(zone())
6049 HElementsKind(boilerplate)); 6075 HElementsKind(boilerplate));
6050 HValue* expected_kind = AddInstruction(new(zone()) 6076 HValue* expected_kind = AddInstruction(new(zone())
6051 HConstant(boilerplate_elements_kind)); 6077 HConstant(boilerplate_elements_kind, Representation::Integer32()));
6052 builder.IfCompare(elements_kind, expected_kind, Token::EQ); 6078 builder.IfCompare(elements_kind, expected_kind, Token::EQ);
6053 builder.Then(); 6079 builder.Then();
6054 builder.ElseDeopt(); 6080 builder.ElseDeopt();
6055 } 6081 }
6056 6082
6057 AddInstruction(new(zone()) HPushArgument(AddInstruction( 6083 AddInstruction(new(zone()) HPushArgument(AddInstruction(
6058 new(zone()) HConstant(literals)))); 6084 new(zone()) HConstant(literals, Representation::Tagged()))));
6059 AddInstruction(new(zone()) HPushArgument(AddInstruction( 6085 AddInstruction(new(zone()) HPushArgument(AddInstruction(
6060 new(zone()) HConstant(literal_index)))); 6086 new(zone()) HConstant(literal_index, Representation::Tagged()))));
6061 AddInstruction(new(zone()) HPushArgument(AddInstruction( 6087 AddInstruction(new(zone()) HPushArgument(AddInstruction(
6062 new(zone()) HConstant(constants)))); 6088 new(zone()) HConstant(constants, Representation::Tagged()))));
6063 6089
6064 Runtime::FunctionId function_id = (expr->depth() > 1) 6090 Runtime::FunctionId function_id = (expr->depth() > 1)
6065 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; 6091 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow;
6066 literal = AddInstruction( 6092 literal = AddInstruction(
6067 new(zone()) HCallRuntime(context, 6093 new(zone()) HCallRuntime(context,
6068 isolate()->factory()->empty_string(), 6094 isolate()->factory()->empty_string(),
6069 Runtime::FunctionForId(function_id), 6095 Runtime::FunctionForId(function_id),
6070 3)); 6096 3));
6071 } 6097 }
6072 6098
6073 // The array is expected in the bailout environment during computation 6099 // The array is expected in the bailout environment during computation
6074 // of the property values and is the value of the entire expression. 6100 // of the property values and is the value of the entire expression.
6075 Push(literal); 6101 Push(literal);
6076 // The literal index is on the stack, too.
6077 Push(AddInstruction(new(zone()) HConstant(expr->literal_index())));
6078 6102
6079 HInstruction* elements = NULL; 6103 HInstruction* elements = NULL;
6080 6104
6081 for (int i = 0; i < length; i++) { 6105 for (int i = 0; i < length; i++) {
6082 Expression* subexpr = subexprs->at(i); 6106 Expression* subexpr = subexprs->at(i);
6083 // If the subexpression is a literal or a simple materialized literal it 6107 // If the subexpression is a literal or a simple materialized literal it
6084 // is already set in the cloned array. 6108 // is already set in the cloned array.
6085 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 6109 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
6086 6110
6087 CHECK_ALIVE(VisitForValue(subexpr)); 6111 CHECK_ALIVE(VisitForValue(subexpr));
(...skipping 17 matching lines...) Expand all
6105 value, 6129 value,
6106 boilerplate_elements_kind)); 6130 boilerplate_elements_kind));
6107 break; 6131 break;
6108 default: 6132 default:
6109 UNREACHABLE(); 6133 UNREACHABLE();
6110 break; 6134 break;
6111 } 6135 }
6112 6136
6113 AddSimulate(expr->GetIdForElement(i)); 6137 AddSimulate(expr->GetIdForElement(i));
6114 } 6138 }
6115
6116 Drop(1); // array literal index
6117 return ast_context()->ReturnValue(Pop()); 6139 return ast_context()->ReturnValue(Pop());
6118 } 6140 }
6119 6141
6120 6142
6121 // Sets the lookup result and returns true if the load/store can be inlined. 6143 // Sets the lookup result and returns true if the load/store can be inlined.
6122 static bool ComputeLoadStoreField(Handle<Map> type, 6144 static bool ComputeLoadStoreField(Handle<Map> type,
6123 Handle<String> name, 6145 Handle<String> name,
6124 LookupResult* lookup, 6146 LookupResult* lookup,
6125 bool is_store) { 6147 bool is_store) {
6126 if (type->has_named_interceptor()) { 6148 if (type->has_named_interceptor()) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6210 HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name); 6232 HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name);
6211 Representation representation = ComputeLoadStoreRepresentation(map, lookup); 6233 Representation representation = ComputeLoadStoreRepresentation(map, lookup);
6212 bool transition_to_field = lookup->IsTransitionToField(*map); 6234 bool transition_to_field = lookup->IsTransitionToField(*map);
6213 6235
6214 HStoreNamedField *instr; 6236 HStoreNamedField *instr;
6215 if (FLAG_track_double_fields && representation.IsDouble()) { 6237 if (FLAG_track_double_fields && representation.IsDouble()) {
6216 if (transition_to_field) { 6238 if (transition_to_field) {
6217 // The store requires a mutable HeapNumber to be allocated. 6239 // The store requires a mutable HeapNumber to be allocated.
6218 NoObservableSideEffectsScope no_side_effects(this); 6240 NoObservableSideEffectsScope no_side_effects(this);
6219 HInstruction* heap_number_size = AddInstruction(new(zone()) HConstant( 6241 HInstruction* heap_number_size = AddInstruction(new(zone()) HConstant(
6220 HeapNumber::kSize)); 6242 HeapNumber::kSize, Representation::Integer32()));
6221 HInstruction* double_box = AddInstruction(new(zone()) HAllocate( 6243 HInstruction* double_box = AddInstruction(new(zone()) HAllocate(
6222 environment()->LookupContext(), heap_number_size, 6244 environment()->LookupContext(), heap_number_size,
6223 HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE)); 6245 HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE));
6224 AddStoreMapConstant(double_box, isolate()->factory()->heap_number_map()); 6246 AddStoreMapConstant(double_box, isolate()->factory()->heap_number_map());
6225 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), 6247 AddStore(double_box, HObjectAccess::ForHeapNumberValue(),
6226 value, Representation::Double()); 6248 value, Representation::Double());
6227 instr = new(zone()) HStoreNamedField(object, field_access, double_box); 6249 instr = new(zone()) HStoreNamedField(object, field_access, double_box);
6228 } else { 6250 } else {
6229 // Already holds a HeapNumber; load the box and write its value field. 6251 // Already holds a HeapNumber; load the box and write its value field.
6230 HInstruction* double_box = AddLoad(object, field_access); 6252 HInstruction* double_box = AddLoad(object, field_access);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6286 if (ComputeLoadStoreField(map, name, &lookup, true)) { 6308 if (ComputeLoadStoreField(map, name, &lookup, true)) {
6287 AddCheckMapsWithTransitions(object, map); 6309 AddCheckMapsWithTransitions(object, map);
6288 return BuildStoreNamedField(object, name, value, map, &lookup); 6310 return BuildStoreNamedField(object, name, value, map, &lookup);
6289 } 6311 }
6290 6312
6291 // No luck, do a generic store. 6313 // No luck, do a generic store.
6292 return BuildStoreNamedGeneric(object, name, value); 6314 return BuildStoreNamedGeneric(object, name, value);
6293 } 6315 }
6294 6316
6295 6317
6296 HInstruction* HOptimizedGraphBuilder::TryLoadPolymorphicAsMonomorphic( 6318 bool HOptimizedGraphBuilder::HandlePolymorphicArrayLengthLoad(
6297 Property* expr, 6319 Property* expr,
6298 HValue* object, 6320 HValue* object,
6299 SmallMapList* types, 6321 SmallMapList* types,
6300 Handle<String> name) { 6322 Handle<String> name) {
6323 if (!name->Equals(isolate()->heap()->length_string())) return false;
6324
6325 for (int i = 0; i < types->length(); i++) {
6326 if (types->at(i)->instance_type() != JS_ARRAY_TYPE) return false;
6327 }
6328
6329 BuildCheckNonSmi(object);
6330
6331 HInstruction* typecheck =
6332 AddInstruction(HCheckMaps::New(object, types, zone()));
6333 HInstruction* instr = new(zone())
6334 HLoadNamedField(object, HObjectAccess::ForArrayLength(), typecheck);
6335
6336 instr->set_position(expr->position());
6337 ast_context()->ReturnInstruction(instr, expr->id());
6338 return true;
6339 }
6340
6341
6342 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr,
6343 HValue* object,
6344 SmallMapList* types,
6345 Handle<String> name) {
6346
6347 if (HandlePolymorphicArrayLengthLoad(expr, object, types, name))
6348 return;
6349
6350 BuildCheckNonSmi(object);
6351
6301 // Use monomorphic load if property lookup results in the same field index 6352 // Use monomorphic load if property lookup results in the same field index
6302 // for all maps. Requires special map check on the set of all handled maps. 6353 // for all maps. Requires special map check on the set of all handled maps.
6354 HInstruction* instr = NULL;
6303 LookupResult lookup(isolate()); 6355 LookupResult lookup(isolate());
6304 int count; 6356 int count;
6305 Representation representation = Representation::None(); 6357 Representation representation = Representation::None();
6306 HObjectAccess access = HObjectAccess::ForMap(); // initial value unused. 6358 HObjectAccess access = HObjectAccess::ForMap(); // initial value unused.
6307 for (count = 0; 6359 for (count = 0;
6308 count < types->length() && count < kMaxLoadPolymorphism; 6360 count < types->length() && count < kMaxLoadPolymorphism;
6309 ++count) { 6361 ++count) {
6310 Handle<Map> map = types->at(count); 6362 Handle<Map> map = types->at(count);
6311 if (!ComputeLoadStoreField(map, name, &lookup, false)) break; 6363 if (!ComputeLoadStoreField(map, name, &lookup, false)) break;
6312 6364
(...skipping 10 matching lines...) Expand all
6323 break; 6375 break;
6324 } else if (access.offset() != new_access.offset()) { 6376 } else if (access.offset() != new_access.offset()) {
6325 // Offsets did not match. 6377 // Offsets did not match.
6326 break; 6378 break;
6327 } else if (access.IsInobject() != new_access.IsInobject()) { 6379 } else if (access.IsInobject() != new_access.IsInobject()) {
6328 // In-objectness did not match. 6380 // In-objectness did not match.
6329 break; 6381 break;
6330 } 6382 }
6331 } 6383 }
6332 6384
6333 if (count != types->length()) return NULL; 6385 if (count == types->length()) {
6334 6386 // Everything matched; can use monomorphic load.
6335 // Everything matched; can use monomorphic load. 6387 AddInstruction(HCheckMaps::New(object, types, zone()));
6336 BuildCheckNonSmi(object); 6388 instr = BuildLoadNamedField(object, access, representation);
6337 AddInstruction(HCheckMaps::New(object, types, zone())); 6389 } else {
6338 return BuildLoadNamedField(object, access, representation);
6339 }
6340
6341
6342 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(
6343 Property* expr,
6344 HValue* object,
6345 SmallMapList* types,
6346 Handle<String> name) {
6347 HInstruction* instr = TryLoadPolymorphicAsMonomorphic(
6348 expr, object, types, name);
6349 if (instr == NULL) {
6350 // Something did not match; must use a polymorphic load. 6390 // Something did not match; must use a polymorphic load.
6351 BuildCheckNonSmi(object);
6352 HValue* context = environment()->LookupContext(); 6391 HValue* context = environment()->LookupContext();
6353 instr = new(zone()) HLoadNamedFieldPolymorphic( 6392 instr = new(zone()) HLoadNamedFieldPolymorphic(
6354 context, object, types, name, zone()); 6393 context, object, types, name, zone());
6355 } 6394 }
6356 6395
6357 instr->set_position(expr->position()); 6396 instr->set_position(expr->position());
6358 return ast_context()->ReturnInstruction(instr, expr->id()); 6397 return ast_context()->ReturnInstruction(instr, expr->id());
6359 } 6398 }
6360 6399
6361 6400
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
6636 return ast_context()->ReturnValue(Pop()); 6675 return ast_context()->ReturnValue(Pop());
6637 6676
6638 } else if (prop != NULL) { 6677 } else if (prop != NULL) {
6639 if (prop->key()->IsPropertyName()) { 6678 if (prop->key()->IsPropertyName()) {
6640 // Named property. 6679 // Named property.
6641 CHECK_ALIVE(VisitForValue(prop->obj())); 6680 CHECK_ALIVE(VisitForValue(prop->obj()));
6642 HValue* object = Top(); 6681 HValue* object = Top();
6643 6682
6644 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); 6683 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
6645 Handle<Map> map; 6684 Handle<Map> map;
6646 HInstruction* load = NULL; 6685 HInstruction* load;
6647 SmallMapList* types = prop->GetReceiverTypes();
6648 bool monomorphic = prop->IsMonomorphic(); 6686 bool monomorphic = prop->IsMonomorphic();
6649 if (monomorphic) { 6687 if (monomorphic) {
6650 map = types->first(); 6688 map = prop->GetReceiverTypes()->first();
6651 // We can't generate code for a monomorphic dict mode load so 6689 // We can't generate code for a monomorphic dict mode load so
6652 // just pretend it is not monomorphic. 6690 // just pretend it is not monomorphic.
6653 if (map->is_dictionary_map()) monomorphic = false; 6691 if (map->is_dictionary_map()) monomorphic = false;
6654 } 6692 }
6655 if (monomorphic) { 6693 if (monomorphic) {
6656 Handle<JSFunction> getter; 6694 Handle<JSFunction> getter;
6657 Handle<JSObject> holder; 6695 Handle<JSObject> holder;
6658 if (LookupGetter(map, name, &getter, &holder)) { 6696 if (LookupGetter(map, name, &getter, &holder)) {
6659 load = BuildCallGetter(object, map, getter, holder); 6697 load = BuildCallGetter(object, map, getter, holder);
6660 } else { 6698 } else {
6661 load = BuildLoadNamedMonomorphic(object, name, prop, map); 6699 load = BuildLoadNamedMonomorphic(object, name, prop, map);
6662 } 6700 }
6663 } else if (types != NULL && types->length() > 1) { 6701 } else {
6664 load = TryLoadPolymorphicAsMonomorphic(prop, object, types, name); 6702 load = BuildLoadNamedGeneric(object, name, prop);
6665 } 6703 }
6666 if (load == NULL) load = BuildLoadNamedGeneric(object, name, prop);
6667 PushAndAdd(load); 6704 PushAndAdd(load);
6668 if (load->HasObservableSideEffects()) { 6705 if (load->HasObservableSideEffects()) {
6669 AddSimulate(prop->LoadId(), REMOVABLE_SIMULATE); 6706 AddSimulate(prop->LoadId(), REMOVABLE_SIMULATE);
6670 } 6707 }
6671 6708
6672 CHECK_ALIVE(VisitForValue(expr->value())); 6709 CHECK_ALIVE(VisitForValue(expr->value()));
6673 HValue* right = Pop(); 6710 HValue* right = Pop();
6674 HValue* left = Pop(); 6711 HValue* left = Pop();
6675 6712
6676 HInstruction* instr = BuildBinaryOperation(operation, left, right); 6713 HInstruction* instr = BuildBinaryOperation(operation, left, right);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
6922 return field; 6959 return field;
6923 } 6960 }
6924 6961
6925 6962
6926 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric( 6963 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric(
6927 HValue* object, 6964 HValue* object,
6928 Handle<String> name, 6965 Handle<String> name,
6929 Property* expr) { 6966 Property* expr) {
6930 if (expr->IsUninitialized()) { 6967 if (expr->IsUninitialized()) {
6931 AddSoftDeoptimize(); 6968 AddSoftDeoptimize();
6932 } else {
6933 // OS::DebugBreak();
6934 } 6969 }
6935 HValue* context = environment()->LookupContext(); 6970 HValue* context = environment()->LookupContext();
6936 return new(zone()) HLoadNamedGeneric(context, object, name); 6971 return new(zone()) HLoadNamedGeneric(context, object, name);
6937 } 6972 }
6938 6973
6939 6974
6940 HInstruction* HOptimizedGraphBuilder::BuildCallGetter( 6975 HInstruction* HOptimizedGraphBuilder::BuildCallGetter(
6941 HValue* object, 6976 HValue* object,
6942 Handle<Map> map, 6977 Handle<Map> map,
6943 Handle<JSFunction> getter, 6978 Handle<JSFunction> getter,
(...skipping 27 matching lines...) Expand all
6971 AddCheckMap(object, map); 7006 AddCheckMap(object, map);
6972 return BuildLoadNamedField(object, 7007 return BuildLoadNamedField(object,
6973 HObjectAccess::ForField(map, &lookup, name), 7008 HObjectAccess::ForField(map, &lookup, name),
6974 ComputeLoadStoreRepresentation(map, &lookup)); 7009 ComputeLoadStoreRepresentation(map, &lookup));
6975 } 7010 }
6976 7011
6977 // Handle a load of a constant known function. 7012 // Handle a load of a constant known function.
6978 if (lookup.IsConstantFunction()) { 7013 if (lookup.IsConstantFunction()) {
6979 AddCheckMap(object, map); 7014 AddCheckMap(object, map);
6980 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); 7015 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map));
6981 return new(zone()) HConstant(function); 7016 return new(zone()) HConstant(function, Representation::Tagged());
6982 } 7017 }
6983 7018
6984 // Handle a load from a known field somewhere in the prototype chain. 7019 // Handle a load from a known field somewhere in the prototype chain.
6985 LookupInPrototypes(map, name, &lookup); 7020 LookupInPrototypes(map, name, &lookup);
6986 if (lookup.IsField()) { 7021 if (lookup.IsField()) {
6987 Handle<JSObject> prototype(JSObject::cast(map->prototype())); 7022 Handle<JSObject> prototype(JSObject::cast(map->prototype()));
6988 Handle<JSObject> holder(lookup.holder()); 7023 Handle<JSObject> holder(lookup.holder());
6989 Handle<Map> holder_map(holder->map()); 7024 Handle<Map> holder_map(holder->map());
6990 AddCheckMap(object, map); 7025 AddCheckMap(object, map);
6991 AddInstruction(new(zone()) HCheckPrototypeMaps( 7026 AddInstruction(new(zone()) HCheckPrototypeMaps(
6992 prototype, holder, zone(), top_info())); 7027 prototype, holder, zone(), top_info()));
6993 HValue* holder_value = AddInstruction(new(zone()) HConstant(holder)); 7028 HValue* holder_value = AddInstruction(new(zone())
7029 HConstant(holder, Representation::Tagged()));
6994 return BuildLoadNamedField(holder_value, 7030 return BuildLoadNamedField(holder_value,
6995 HObjectAccess::ForField(holder_map, &lookup, name), 7031 HObjectAccess::ForField(holder_map, &lookup, name),
6996 ComputeLoadStoreRepresentation(map, &lookup)); 7032 ComputeLoadStoreRepresentation(map, &lookup));
6997 } 7033 }
6998 7034
6999 // Handle a load of a constant function somewhere in the prototype chain. 7035 // Handle a load of a constant function somewhere in the prototype chain.
7000 if (lookup.IsConstantFunction()) { 7036 if (lookup.IsConstantFunction()) {
7001 Handle<JSObject> prototype(JSObject::cast(map->prototype())); 7037 Handle<JSObject> prototype(JSObject::cast(map->prototype()));
7002 Handle<JSObject> holder(lookup.holder()); 7038 Handle<JSObject> holder(lookup.holder());
7003 Handle<Map> holder_map(holder->map()); 7039 Handle<Map> holder_map(holder->map());
7004 AddCheckMap(object, map); 7040 AddCheckMap(object, map);
7005 AddInstruction(new(zone()) HCheckPrototypeMaps( 7041 AddInstruction(new(zone()) HCheckPrototypeMaps(
7006 prototype, holder, zone(), top_info())); 7042 prototype, holder, zone(), top_info()));
7007 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map)); 7043 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map));
7008 return new(zone()) HConstant(function); 7044 return new(zone()) HConstant(function, Representation::Tagged());
7009 } 7045 }
7010 7046
7011 // No luck, do a generic load. 7047 // No luck, do a generic load.
7012 return BuildLoadNamedGeneric(object, name, expr); 7048 return BuildLoadNamedGeneric(object, name, expr);
7013 } 7049 }
7014 7050
7015 7051
7016 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, 7052 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object,
7017 HValue* key) { 7053 HValue* key) {
7018 HValue* context = environment()->LookupContext(); 7054 HValue* context = environment()->LookupContext();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
7385 void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() { 7421 void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() {
7386 // Outermost function already has arguments on the stack. 7422 // Outermost function already has arguments on the stack.
7387 if (function_state()->outer() == NULL) return; 7423 if (function_state()->outer() == NULL) return;
7388 7424
7389 if (function_state()->arguments_pushed()) return; 7425 if (function_state()->arguments_pushed()) return;
7390 7426
7391 // Push arguments when entering inlined function. 7427 // Push arguments when entering inlined function.
7392 HEnterInlined* entry = function_state()->entry(); 7428 HEnterInlined* entry = function_state()->entry();
7393 entry->set_arguments_pushed(); 7429 entry->set_arguments_pushed();
7394 7430
7395 HArgumentsObject* arguments = entry->arguments_object(); 7431 ZoneList<HValue*>* arguments_values = entry->arguments_values();
7396 const ZoneList<HValue*>* arguments_values = arguments->arguments_values();
7397 7432
7398 HInstruction* insert_after = entry; 7433 HInstruction* insert_after = entry;
7399 for (int i = 0; i < arguments_values->length(); i++) { 7434 for (int i = 0; i < arguments_values->length(); i++) {
7400 HValue* argument = arguments_values->at(i); 7435 HValue* argument = arguments_values->at(i);
7401 HInstruction* push_argument = new(zone()) HPushArgument(argument); 7436 HInstruction* push_argument = new(zone()) HPushArgument(argument);
7402 push_argument->InsertAfter(insert_after); 7437 push_argument->InsertAfter(insert_after);
7403 insert_after = push_argument; 7438 insert_after = push_argument;
7404 } 7439 }
7405 7440
7406 HArgumentsElements* arguments_elements = 7441 HArgumentsElements* arguments_elements =
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
7979 undefined, 8014 undefined,
7980 function_state()->inlining_kind(), 8015 function_state()->inlining_kind(),
7981 undefined_receiver); 8016 undefined_receiver);
7982 #ifdef V8_TARGET_ARCH_IA32 8017 #ifdef V8_TARGET_ARCH_IA32
7983 // IA32 only, overwrite the caller's context in the deoptimization 8018 // IA32 only, overwrite the caller's context in the deoptimization
7984 // environment with the correct one. 8019 // environment with the correct one.
7985 // 8020 //
7986 // TODO(kmillikin): implement the same inlining on other platforms so we 8021 // TODO(kmillikin): implement the same inlining on other platforms so we
7987 // can remove the unsightly ifdefs in this function. 8022 // can remove the unsightly ifdefs in this function.
7988 HConstant* context = 8023 HConstant* context =
7989 new(zone()) HConstant(Handle<Context>(target->context())); 8024 new(zone()) HConstant(Handle<Context>(target->context()),
8025 Representation::Tagged());
7990 AddInstruction(context); 8026 AddInstruction(context);
7991 inner_env->BindContext(context); 8027 inner_env->BindContext(context);
7992 #endif 8028 #endif
7993 8029
7994 AddSimulate(return_id); 8030 AddSimulate(return_id);
7995 current_block()->UpdateEnvironment(inner_env); 8031 current_block()->UpdateEnvironment(inner_env);
7996 HArgumentsObject* arguments_object = NULL; 8032 ZoneList<HValue*>* arguments_values = NULL;
7997 8033
7998 // If the function uses arguments object create and bind one, also copy 8034 // If the function uses arguments copy current arguments values
7999 // current arguments values to use them for materialization. 8035 // to use them for materialization.
8000 if (function->scope()->arguments() != NULL) { 8036 if (function->scope()->arguments() != NULL) {
8001 ASSERT(function->scope()->arguments()->IsStackAllocated());
8002 HEnvironment* arguments_env = inner_env->arguments_environment(); 8037 HEnvironment* arguments_env = inner_env->arguments_environment();
8003 int arguments_count = arguments_env->parameter_count(); 8038 int arguments_count = arguments_env->parameter_count();
8004 arguments_object = new(zone()) HArgumentsObject(arguments_count, zone()); 8039 arguments_values = new(zone()) ZoneList<HValue*>(arguments_count, zone());
8005 inner_env->Bind(function->scope()->arguments(), arguments_object);
8006 for (int i = 0; i < arguments_count; i++) { 8040 for (int i = 0; i < arguments_count; i++) {
8007 arguments_object->AddArgument(arguments_env->Lookup(i), zone()); 8041 arguments_values->Add(arguments_env->Lookup(i), zone());
8008 } 8042 }
8009 AddInstruction(arguments_object);
8010 } 8043 }
8011 8044
8012 HEnterInlined* enter_inlined = 8045 HEnterInlined* enter_inlined =
8013 new(zone()) HEnterInlined(target, 8046 new(zone()) HEnterInlined(target,
8014 arguments_count, 8047 arguments_count,
8015 function, 8048 function,
8016 function_state()->inlining_kind(), 8049 function_state()->inlining_kind(),
8017 function->scope()->arguments(), 8050 function->scope()->arguments(),
8018 arguments_object, 8051 arguments_values,
8019 undefined_receiver, 8052 undefined_receiver,
8020 zone()); 8053 zone());
8021 function_state()->set_entry(enter_inlined); 8054 function_state()->set_entry(enter_inlined);
8022 AddInstruction(enter_inlined); 8055 AddInstruction(enter_inlined);
8023 8056
8057 // If the function uses arguments object create and bind one.
8058 if (function->scope()->arguments() != NULL) {
8059 ASSERT(function->scope()->arguments()->IsStackAllocated());
8060 inner_env->Bind(function->scope()->arguments(),
8061 graph()->GetArgumentsObject());
8062 }
8063
8064
8024 VisitDeclarations(target_info.scope()->declarations()); 8065 VisitDeclarations(target_info.scope()->declarations());
8025 VisitStatements(function->body()); 8066 VisitStatements(function->body());
8026 if (HasStackOverflow()) { 8067 if (HasStackOverflow()) {
8027 // Bail out if the inline function did, as we cannot residualize a call 8068 // Bail out if the inline function did, as we cannot residualize a call
8028 // instead. 8069 // instead.
8029 TraceInline(target, caller, "inline graph construction failed"); 8070 TraceInline(target, caller, "inline graph construction failed");
8030 target_shared->DisableOptimization("inlining bailed out"); 8071 target_shared->DisableOptimization("inlining bailed out");
8031 inline_bailout_ = true; 8072 inline_bailout_ = true;
8032 delete target_state; 8073 delete target_state;
8033 return true; 8074 return true;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
8319 Pop(); // Pop receiver. 8360 Pop(); // Pop receiver.
8320 HValue* context = environment()->LookupContext(); 8361 HValue* context = environment()->LookupContext();
8321 HInstruction* result = NULL; 8362 HInstruction* result = NULL;
8322 // Use sqrt() if exponent is 0.5 or -0.5. 8363 // Use sqrt() if exponent is 0.5 or -0.5.
8323 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { 8364 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) {
8324 double exponent = HConstant::cast(right)->DoubleValue(); 8365 double exponent = HConstant::cast(right)->DoubleValue();
8325 if (exponent == 0.5) { 8366 if (exponent == 0.5) {
8326 result = 8367 result =
8327 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); 8368 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf);
8328 } else if (exponent == -0.5) { 8369 } else if (exponent == -0.5) {
8329 HValue* one = graph()->GetConstant1(); 8370 HConstant* double_one = new(zone()) HConstant(
8371 1, Representation::Double());
8372 AddInstruction(double_one);
8330 HInstruction* sqrt = 8373 HInstruction* sqrt =
8331 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); 8374 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf);
8332 AddInstruction(sqrt); 8375 AddInstruction(sqrt);
8333 // MathPowHalf doesn't have side effects so there's no need for 8376 // MathPowHalf doesn't have side effects so there's no need for
8334 // an environment simulation here. 8377 // an environment simulation here.
8335 ASSERT(!sqrt->HasObservableSideEffects()); 8378 ASSERT(!sqrt->HasObservableSideEffects());
8336 result = HDiv::New(zone(), context, one, sqrt); 8379 result = HDiv::New(zone(), context, double_one, sqrt);
8337 } else if (exponent == 2.0) { 8380 } else if (exponent == 2.0) {
8338 result = HMul::New(zone(), context, left, left); 8381 result = HMul::New(zone(), context, left, left);
8339 } 8382 }
8340 } else if (right->EqualsInteger32Constant(2)) { 8383 } else if (right->EqualsInteger32Constant(2)) {
8341 result = HMul::New(zone(), context, left, left); 8384 result = HMul::New(zone(), context, left, left);
8342 } 8385 }
8343 8386
8344 if (result == NULL) { 8387 if (result == NULL) {
8345 result = HPower::New(zone(), left, right); 8388 result = HPower::New(zone(), left, right);
8346 } 8389 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
8443 new(zone()) HApplyArguments(function, 8486 new(zone()) HApplyArguments(function,
8444 wrapped_receiver, 8487 wrapped_receiver,
8445 length, 8488 length,
8446 elements); 8489 elements);
8447 result->set_position(expr->position()); 8490 result->set_position(expr->position());
8448 ast_context()->ReturnInstruction(result, expr->id()); 8491 ast_context()->ReturnInstruction(result, expr->id());
8449 return true; 8492 return true;
8450 } else { 8493 } else {
8451 // We are inside inlined function and we know exactly what is inside 8494 // We are inside inlined function and we know exactly what is inside
8452 // arguments object. But we need to be able to materialize at deopt. 8495 // arguments object. But we need to be able to materialize at deopt.
8496 // TODO(mstarzinger): For now we just ensure arguments are pushed
8497 // right after HEnterInlined, but we could be smarter about this.
8498 EnsureArgumentsArePushedForAccess();
8453 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), 8499 ASSERT_EQ(environment()->arguments_environment()->parameter_count(),
8454 function_state()->entry()->arguments_object()->arguments_count()); 8500 function_state()->entry()->arguments_values()->length());
8455 HArgumentsObject* args = function_state()->entry()->arguments_object(); 8501 HEnterInlined* entry = function_state()->entry();
8456 const ZoneList<HValue*>* arguments_values = args->arguments_values(); 8502 ZoneList<HValue*>* arguments_values = entry->arguments_values();
8457 int arguments_count = arguments_values->length(); 8503 int arguments_count = arguments_values->length();
8458 PushAndAdd(new(zone()) HWrapReceiver(receiver, function)); 8504 PushAndAdd(new(zone()) HWrapReceiver(receiver, function));
8459 for (int i = 1; i < arguments_count; i++) { 8505 for (int i = 1; i < arguments_count; i++) {
8460 Push(arguments_values->at(i)); 8506 Push(arguments_values->at(i));
8461 } 8507 }
8462 8508
8463 Handle<JSFunction> known_function; 8509 Handle<JSFunction> known_function;
8464 if (function->IsConstant()) { 8510 if (function->IsConstant()) {
8465 HConstant* constant_function = HConstant::cast(function); 8511 HConstant* constant_function = HConstant::cast(function);
8466 known_function = Handle<JSFunction>::cast(constant_function->handle()); 8512 known_function = Handle<JSFunction>::cast(constant_function->handle());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
8792 } 8838 }
8793 8839
8794 // Calculate instance size from initial map of constructor. 8840 // Calculate instance size from initial map of constructor.
8795 ASSERT(constructor->has_initial_map()); 8841 ASSERT(constructor->has_initial_map());
8796 Handle<Map> initial_map(constructor->initial_map()); 8842 Handle<Map> initial_map(constructor->initial_map());
8797 int instance_size = initial_map->instance_size(); 8843 int instance_size = initial_map->instance_size();
8798 ASSERT(initial_map->InitialPropertiesLength() == 0); 8844 ASSERT(initial_map->InitialPropertiesLength() == 0);
8799 8845
8800 // Allocate an instance of the implicit receiver object. 8846 // Allocate an instance of the implicit receiver object.
8801 HValue* size_in_bytes = 8847 HValue* size_in_bytes =
8802 AddInstruction(new(zone()) HConstant(instance_size)); 8848 AddInstruction(new(zone()) HConstant(instance_size,
8849 Representation::Integer32()));
8803 8850
8804 HAllocate::Flags flags = HAllocate::DefaultFlags(); 8851 HAllocate::Flags flags = HAllocate::DefaultFlags();
8805 if (FLAG_pretenuring_call_new && 8852 if (FLAG_pretenuring_call_new &&
8806 isolate()->heap()->ShouldGloballyPretenure()) { 8853 isolate()->heap()->ShouldGloballyPretenure()) {
8807 flags = static_cast<HAllocate::Flags>( 8854 flags = static_cast<HAllocate::Flags>(
8808 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); 8855 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
8809 } 8856 }
8810 8857
8811 HInstruction* receiver = 8858 HInstruction* receiver =
8812 AddInstruction(new(zone()) HAllocate(context, 8859 AddInstruction(new(zone()) HAllocate(context,
8813 size_in_bytes, 8860 size_in_bytes,
8814 HType::JSObject(), 8861 HType::JSObject(),
8815 flags)); 8862 flags));
8816 HAllocate::cast(receiver)->set_known_initial_map(initial_map); 8863 HAllocate::cast(receiver)->set_known_initial_map(initial_map);
8817 8864
8818 // Load the initial map from the constructor. 8865 // Load the initial map from the constructor.
8819 HValue* constructor_value = 8866 HValue* constructor_value =
8820 AddInstruction(new(zone()) HConstant(constructor)); 8867 AddInstruction(new(zone()) HConstant(constructor,
8868 Representation::Tagged()));
8821 HValue* initial_map_value = 8869 HValue* initial_map_value =
8822 AddLoad(constructor_value, HObjectAccess::ForJSObjectOffset( 8870 AddLoad(constructor_value, HObjectAccess::ForJSObjectOffset(
8823 JSFunction::kPrototypeOrInitialMapOffset)); 8871 JSFunction::kPrototypeOrInitialMapOffset));
8824 8872
8825 // Initialize map and fields of the newly allocated object. 8873 // Initialize map and fields of the newly allocated object.
8826 { NoObservableSideEffectsScope no_effects(this); 8874 { NoObservableSideEffectsScope no_effects(this);
8827 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); 8875 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
8828 AddStore(receiver, 8876 AddStore(receiver,
8829 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), 8877 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset),
8830 initial_map_value); 8878 initial_map_value);
8831 HValue* empty_fixed_array = 8879 HValue* empty_fixed_array =
8832 AddInstruction(new(zone()) HConstant(factory->empty_fixed_array())); 8880 AddInstruction(new(zone()) HConstant(factory->empty_fixed_array(),
8881 Representation::Tagged()));
8833 AddStore(receiver, 8882 AddStore(receiver,
8834 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), 8883 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset),
8835 empty_fixed_array); 8884 empty_fixed_array);
8836 AddStore(receiver, 8885 AddStore(receiver,
8837 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), 8886 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset),
8838 empty_fixed_array); 8887 empty_fixed_array);
8839 if (initial_map->inobject_properties() != 0) { 8888 if (initial_map->inobject_properties() != 0) {
8840 HConstant* undefined = graph()->GetConstantUndefined(); 8889 HConstant* undefined = graph()->GetConstantUndefined();
8841 for (int i = 0; i < initial_map->inobject_properties(); i++) { 8890 for (int i = 0; i < initial_map->inobject_properties(); i++) {
8842 int property_offset = JSObject::kHeaderSize + i * kPointerSize; 8891 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
9218 9267
9219 if (prop->key()->IsPropertyName()) { 9268 if (prop->key()->IsPropertyName()) {
9220 // Named property. 9269 // Named property.
9221 if (returns_original_input) Push(graph()->GetConstantUndefined()); 9270 if (returns_original_input) Push(graph()->GetConstantUndefined());
9222 9271
9223 CHECK_ALIVE(VisitForValue(prop->obj())); 9272 CHECK_ALIVE(VisitForValue(prop->obj()));
9224 HValue* object = Top(); 9273 HValue* object = Top();
9225 9274
9226 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); 9275 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
9227 Handle<Map> map; 9276 Handle<Map> map;
9228 HInstruction* load = NULL; 9277 HInstruction* load;
9229 bool monomorphic = prop->IsMonomorphic(); 9278 bool monomorphic = prop->IsMonomorphic();
9230 SmallMapList* types = prop->GetReceiverTypes();
9231 if (monomorphic) { 9279 if (monomorphic) {
9232 map = types->first(); 9280 map = prop->GetReceiverTypes()->first();
9233 if (map->is_dictionary_map()) monomorphic = false; 9281 if (map->is_dictionary_map()) monomorphic = false;
9234 } 9282 }
9235 if (monomorphic) { 9283 if (monomorphic) {
9236 Handle<JSFunction> getter; 9284 Handle<JSFunction> getter;
9237 Handle<JSObject> holder; 9285 Handle<JSObject> holder;
9238 if (LookupGetter(map, name, &getter, &holder)) { 9286 if (LookupGetter(map, name, &getter, &holder)) {
9239 load = BuildCallGetter(object, map, getter, holder); 9287 load = BuildCallGetter(object, map, getter, holder);
9240 } else { 9288 } else {
9241 load = BuildLoadNamedMonomorphic(object, name, prop, map); 9289 load = BuildLoadNamedMonomorphic(object, name, prop, map);
9242 } 9290 }
9243 } else if (types != NULL && types->length() > 1) { 9291 } else {
9244 load = TryLoadPolymorphicAsMonomorphic(prop, object, types, name); 9292 load = BuildLoadNamedGeneric(object, name, prop);
9245 } 9293 }
9246 if (load == NULL) load = BuildLoadNamedGeneric(object, name, prop);
9247 PushAndAdd(load); 9294 PushAndAdd(load);
9248 if (load->HasObservableSideEffects()) { 9295 if (load->HasObservableSideEffects()) {
9249 AddSimulate(prop->LoadId(), REMOVABLE_SIMULATE); 9296 AddSimulate(prop->LoadId(), REMOVABLE_SIMULATE);
9250 } 9297 }
9251 9298
9252 after = BuildIncrement(returns_original_input, expr); 9299 after = BuildIncrement(returns_original_input, expr);
9253 input = Pop(); 9300 input = Pop();
9254 9301
9255 HInstruction* store; 9302 HInstruction* store;
9256 if (!monomorphic || map->is_observed()) { 9303 if (!monomorphic || map->is_observed()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
9324 HValue* context, 9371 HValue* context,
9325 HValue* string, 9372 HValue* string,
9326 HValue* index) { 9373 HValue* index) {
9327 if (string->IsConstant() && index->IsConstant()) { 9374 if (string->IsConstant() && index->IsConstant()) {
9328 HConstant* c_string = HConstant::cast(string); 9375 HConstant* c_string = HConstant::cast(string);
9329 HConstant* c_index = HConstant::cast(index); 9376 HConstant* c_index = HConstant::cast(index);
9330 if (c_string->HasStringValue() && c_index->HasNumberValue()) { 9377 if (c_string->HasStringValue() && c_index->HasNumberValue()) {
9331 int32_t i = c_index->NumberValueAsInteger32(); 9378 int32_t i = c_index->NumberValueAsInteger32();
9332 Handle<String> s = c_string->StringValue(); 9379 Handle<String> s = c_string->StringValue();
9333 if (i < 0 || i >= s->length()) { 9380 if (i < 0 || i >= s->length()) {
9334 return new(zone()) HConstant(OS::nan_value()); 9381 return new(zone()) HConstant(OS::nan_value(), Representation::Double());
9335 } 9382 }
9336 return new(zone()) HConstant(s->Get(i)); 9383 return new(zone()) HConstant(s->Get(i));
9337 } 9384 }
9338 } 9385 }
9339 BuildCheckNonSmi(string); 9386 BuildCheckNonSmi(string);
9340 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 9387 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
9341 HInstruction* length = HStringLength::New(zone(), string); 9388 HInstruction* length = HStringLength::New(zone(), string);
9342 AddInstruction(length); 9389 AddInstruction(length);
9343 HInstruction* checked_index = AddBoundsCheck(index, length); 9390 HInstruction* checked_index = AddBoundsCheck(index, length);
9344 return new(zone()) HStringCharCodeAt(context, string, checked_index); 9391 return new(zone()) HStringCharCodeAt(context, string, checked_index);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
9639 HValue* left = Pop(); 9686 HValue* left = Pop();
9640 HInstruction* instr = BuildBinaryOperation(expr, left, right); 9687 HInstruction* instr = BuildBinaryOperation(expr, left, right);
9641 instr->set_position(expr->position()); 9688 instr->set_position(expr->position());
9642 return ast_context()->ReturnInstruction(instr, expr->id()); 9689 return ast_context()->ReturnInstruction(instr, expr->id());
9643 } 9690 }
9644 9691
9645 9692
9646 // TODO(rossberg): this should die eventually. 9693 // TODO(rossberg): this should die eventually.
9647 Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) { 9694 Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) {
9648 if (info.IsUninitialized()) return Representation::None(); 9695 if (info.IsUninitialized()) return Representation::None();
9649 // TODO(verwaest): Return Smi rather than Integer32.
9650 if (info.IsSmi()) return Representation::Integer32(); 9696 if (info.IsSmi()) return Representation::Integer32();
9651 if (info.IsInteger32()) return Representation::Integer32(); 9697 if (info.IsInteger32()) return Representation::Integer32();
9652 if (info.IsDouble()) return Representation::Double(); 9698 if (info.IsDouble()) return Representation::Double();
9653 if (info.IsNumber()) return Representation::Double(); 9699 if (info.IsNumber()) return Representation::Double();
9654 return Representation::Tagged(); 9700 return Representation::Tagged();
9655 } 9701 }
9656 9702
9657 9703
9658 Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) { 9704 Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) {
9659 if (type->Is(Type::None())) return Representation::None(); 9705 if (type->Is(Type::None())) return Representation::None();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
9873 return ast_context()->ReturnControl(result, expr->id()); 9919 return ast_context()->ReturnControl(result, expr->id());
9874 } else { 9920 } else {
9875 if (combined_rep.IsTagged() || combined_rep.IsNone()) { 9921 if (combined_rep.IsTagged() || combined_rep.IsNone()) {
9876 HCompareGeneric* result = 9922 HCompareGeneric* result =
9877 new(zone()) HCompareGeneric(context, left, right, op); 9923 new(zone()) HCompareGeneric(context, left, right, op);
9878 result->set_observed_input_representation(1, left_rep); 9924 result->set_observed_input_representation(1, left_rep);
9879 result->set_observed_input_representation(2, right_rep); 9925 result->set_observed_input_representation(2, right_rep);
9880 result->set_position(expr->position()); 9926 result->set_position(expr->position());
9881 return ast_context()->ReturnInstruction(result, expr->id()); 9927 return ast_context()->ReturnInstruction(result, expr->id());
9882 } else { 9928 } else {
9883 // TODO(verwaest): Remove once ToRepresentation properly returns Smi when
9884 // the IC measures Smi.
9885 if (left_type->Is(Type::Integer31())) left_rep = Representation::Smi();
9886 if (right_type->Is(Type::Integer31())) right_rep = Representation::Smi();
9887 HCompareIDAndBranch* result = 9929 HCompareIDAndBranch* result =
9888 new(zone()) HCompareIDAndBranch(left, right, op); 9930 new(zone()) HCompareIDAndBranch(left, right, op);
9889 result->set_observed_input_representation(left_rep, right_rep); 9931 result->set_observed_input_representation(left_rep, right_rep);
9890 result->set_position(expr->position()); 9932 result->set_position(expr->position());
9891 return ast_context()->ReturnControl(result, expr->id()); 9933 return ast_context()->ReturnControl(result, expr->id());
9892 } 9934 }
9893 } 9935 }
9894 } 9936 }
9895 9937
9896 9938
(...skipping 20 matching lines...) Expand all
9917 BuildCompareNil(value, type, expr->position(), &continuation); 9959 BuildCompareNil(value, type, expr->position(), &continuation);
9918 return ast_context()->ReturnContinuation(&continuation, expr->id()); 9960 return ast_context()->ReturnContinuation(&continuation, expr->id());
9919 } 9961 }
9920 9962
9921 9963
9922 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { 9964 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() {
9923 // If we share optimized code between different closures, the 9965 // If we share optimized code between different closures, the
9924 // this-function is not a constant, except inside an inlined body. 9966 // this-function is not a constant, except inside an inlined body.
9925 if (function_state()->outer() != NULL) { 9967 if (function_state()->outer() != NULL) {
9926 return new(zone()) HConstant( 9968 return new(zone()) HConstant(
9927 function_state()->compilation_info()->closure()); 9969 function_state()->compilation_info()->closure(),
9970 Representation::Tagged());
9928 } else { 9971 } else {
9929 return new(zone()) HThisFunction; 9972 return new(zone()) HThisFunction;
9930 } 9973 }
9931 } 9974 }
9932 9975
9933 9976
9934 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( 9977 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
9935 HValue* context, 9978 HValue* context,
9936 Handle<JSObject> boilerplate_object, 9979 Handle<JSObject> boilerplate_object,
9937 Handle<JSObject> original_boilerplate_object, 9980 Handle<JSObject> original_boilerplate_object,
9938 int data_size, 9981 int data_size,
9939 int pointer_size, 9982 int pointer_size,
9940 AllocationSiteMode mode) { 9983 AllocationSiteMode mode) {
9941 Zone* zone = this->zone(); 9984 Zone* zone = this->zone();
9942 int total_size = data_size + pointer_size; 9985 int total_size = data_size + pointer_size;
9943 9986
9944 NoObservableSideEffectsScope no_effects(this); 9987 NoObservableSideEffectsScope no_effects(this);
9945 9988
9946 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; 9989 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
9947 // TODO(hpayer): add support for old data space 9990 // TODO(hpayer): add support for old data space
9948 if (isolate()->heap()->ShouldGloballyPretenure() && 9991 if (isolate()->heap()->ShouldGloballyPretenure() &&
9949 data_size == 0) { 9992 data_size == 0) {
9950 flags = static_cast<HAllocate::Flags>( 9993 flags = static_cast<HAllocate::Flags>(
9951 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); 9994 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
9952 } 9995 }
9953 9996
9954 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(total_size)); 9997 HValue* size_in_bytes =
9998 AddInstruction(new(zone) HConstant(total_size,
9999 Representation::Integer32()));
9955 HInstruction* result = 10000 HInstruction* result =
9956 AddInstruction(new(zone) HAllocate(context, 10001 AddInstruction(new(zone) HAllocate(context,
9957 size_in_bytes, 10002 size_in_bytes,
9958 HType::JSObject(), 10003 HType::JSObject(),
9959 flags)); 10004 flags));
9960 int offset = 0; 10005 int offset = 0;
9961 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, 10006 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result,
9962 &offset, mode); 10007 &offset, mode);
9963 return result; 10008 return result;
9964 } 10009 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
10001 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); 10046 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset));
10002 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, 10047 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object,
10003 object_properties, target, offset); 10048 object_properties, target, offset);
10004 10049
10005 // Create allocation site info. 10050 // Create allocation site info.
10006 if (mode == TRACK_ALLOCATION_SITE && 10051 if (mode == TRACK_ALLOCATION_SITE &&
10007 boilerplate_object->map()->CanTrackAllocationSite()) { 10052 boilerplate_object->map()->CanTrackAllocationSite()) {
10008 elements_offset += AllocationSiteInfo::kSize; 10053 elements_offset += AllocationSiteInfo::kSize;
10009 *offset += AllocationSiteInfo::kSize; 10054 *offset += AllocationSiteInfo::kSize;
10010 HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( 10055 HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant(
10011 original_boilerplate_object)); 10056 original_boilerplate_object, Representation::Tagged()));
10012 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); 10057 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate);
10013 } 10058 }
10014 } 10059 }
10015 10060
10016 10061
10017 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( 10062 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader(
10018 Handle<JSObject> boilerplate_object, 10063 Handle<JSObject> boilerplate_object,
10019 HInstruction* target, 10064 HInstruction* target,
10020 int object_offset, 10065 int object_offset,
10021 int elements_offset, 10066 int elements_offset,
10022 int elements_size) { 10067 int elements_size) {
10023 ASSERT(boilerplate_object->properties()->length() == 0); 10068 ASSERT(boilerplate_object->properties()->length() == 0);
10024 Zone* zone = this->zone(); 10069 Zone* zone = this->zone();
10025 HValue* result = NULL; 10070 HValue* result = NULL;
10026 10071
10027 HValue* object_header = 10072 HValue* object_header =
10028 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); 10073 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset));
10029 Handle<Map> boilerplate_object_map(boilerplate_object->map()); 10074 Handle<Map> boilerplate_object_map(boilerplate_object->map());
10030 AddStoreMapConstant(object_header, boilerplate_object_map); 10075 AddStoreMapConstant(object_header, boilerplate_object_map);
10031 10076
10032 HInstruction* elements; 10077 HInstruction* elements;
10033 if (elements_size == 0) { 10078 if (elements_size == 0) {
10034 Handle<Object> elements_field = 10079 Handle<Object> elements_field =
10035 Handle<Object>(boilerplate_object->elements(), isolate()); 10080 Handle<Object>(boilerplate_object->elements(), isolate());
10036 elements = AddInstruction(new(zone) HConstant(elements_field)); 10081 elements = AddInstruction(new(zone) HConstant(
10082 elements_field, Representation::Tagged()));
10037 } else { 10083 } else {
10038 elements = AddInstruction(new(zone) HInnerAllocatedObject( 10084 elements = AddInstruction(new(zone) HInnerAllocatedObject(
10039 target, elements_offset)); 10085 target, elements_offset));
10040 result = elements; 10086 result = elements;
10041 } 10087 }
10042 AddStore(object_header, HObjectAccess::ForElementsPointer(), elements); 10088 AddStore(object_header, HObjectAccess::ForElementsPointer(), elements);
10043 10089
10044 Handle<Object> properties_field = 10090 Handle<Object> properties_field =
10045 Handle<Object>(boilerplate_object->properties(), isolate()); 10091 Handle<Object>(boilerplate_object->properties(), isolate());
10046 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); 10092 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array());
10047 HInstruction* properties = AddInstruction(new(zone) HConstant( 10093 HInstruction* properties = AddInstruction(new(zone) HConstant(
10048 properties_field)); 10094 properties_field, Representation::None()));
10049 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 10095 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
10050 AddStore(object_header, access, properties); 10096 AddStore(object_header, access, properties);
10051 10097
10052 if (boilerplate_object->IsJSArray()) { 10098 if (boilerplate_object->IsJSArray()) {
10053 Handle<JSArray> boilerplate_array = 10099 Handle<JSArray> boilerplate_array =
10054 Handle<JSArray>::cast(boilerplate_object); 10100 Handle<JSArray>::cast(boilerplate_object);
10055 Handle<Object> length_field = 10101 Handle<Object> length_field =
10056 Handle<Object>(boilerplate_array->length(), isolate()); 10102 Handle<Object>(boilerplate_array->length(), isolate());
10057 HInstruction* length = AddInstruction(new(zone) HConstant(length_field)); 10103 HInstruction* length = AddInstruction(new(zone) HConstant(
10104 length_field, Representation::None()));
10058 10105
10059 ASSERT(boilerplate_array->length()->IsSmi()); 10106 ASSERT(boilerplate_array->length()->IsSmi());
10060 Representation representation = 10107 Representation representation =
10061 IsFastElementsKind(boilerplate_array->GetElementsKind()) 10108 IsFastElementsKind(boilerplate_array->GetElementsKind())
10062 ? Representation::Smi() : Representation::Tagged(); 10109 ? Representation::Smi() : Representation::Tagged();
10063 AddStore(object_header, HObjectAccess::ForArrayLength(), 10110 AddStore(object_header, HObjectAccess::ForArrayLength(),
10064 length, representation); 10111 length, representation);
10065 } 10112 }
10066 10113
10067 return result; 10114 return result;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
10103 isolate())); 10150 isolate()));
10104 HInstruction* value_instruction = 10151 HInstruction* value_instruction =
10105 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); 10152 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset));
10106 10153
10107 AddStore(object_properties, access, value_instruction); 10154 AddStore(object_properties, access, value_instruction);
10108 10155
10109 BuildEmitDeepCopy(value_object, original_value_object, target, 10156 BuildEmitDeepCopy(value_object, original_value_object, target,
10110 offset, DONT_TRACK_ALLOCATION_SITE); 10157 offset, DONT_TRACK_ALLOCATION_SITE);
10111 } else { 10158 } else {
10112 Representation representation = details.representation(); 10159 Representation representation = details.representation();
10113 HInstruction* value_instruction = 10160 HInstruction* value_instruction = AddInstruction(new(zone) HConstant(
10114 AddInstruction(new(zone) HConstant(value)); 10161 value, Representation::Tagged()));
10115 10162
10116 if (representation.IsDouble()) { 10163 if (representation.IsDouble()) {
10117 // Allocate a HeapNumber box and store the value into it. 10164 // Allocate a HeapNumber box and store the value into it.
10118 HInstruction* double_box = 10165 HInstruction* double_box =
10119 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); 10166 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset));
10120 AddStoreMapConstant(double_box, 10167 AddStoreMapConstant(double_box,
10121 isolate()->factory()->heap_number_map()); 10168 isolate()->factory()->heap_number_map());
10122 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), 10169 AddStore(double_box, HObjectAccess::ForHeapNumberValue(),
10123 value_instruction, Representation::Double()); 10170 value_instruction, Representation::Double());
10124 value_instruction = double_box; 10171 value_instruction = double_box;
10125 *offset += HeapNumber::kSize; 10172 *offset += HeapNumber::kSize;
10126 } 10173 }
10127 10174
10128 AddStore(object_properties, access, value_instruction); 10175 AddStore(object_properties, access, value_instruction);
10129 } 10176 }
10130 } 10177 }
10131 10178
10132 int inobject_properties = boilerplate_object->map()->inobject_properties(); 10179 int inobject_properties = boilerplate_object->map()->inobject_properties();
10133 HInstruction* value_instruction = AddInstruction(new(zone) 10180 HInstruction* value_instruction = AddInstruction(new(zone)
10134 HConstant(isolate()->factory()->one_pointer_filler_map())); 10181 HConstant(isolate()->factory()->one_pointer_filler_map(),
10182 Representation::Tagged()));
10135 for (int i = copied_fields; i < inobject_properties; i++) { 10183 for (int i = copied_fields; i < inobject_properties; i++) {
10136 ASSERT(boilerplate_object->IsJSObject()); 10184 ASSERT(boilerplate_object->IsJSObject());
10137 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 10185 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
10138 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); 10186 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset);
10139 AddStore(object_properties, access, value_instruction); 10187 AddStore(object_properties, access, value_instruction);
10140 } 10188 }
10141 } 10189 }
10142 10190
10143 10191
10144 void HOptimizedGraphBuilder::BuildEmitElements( 10192 void HOptimizedGraphBuilder::BuildEmitElements(
(...skipping 21 matching lines...) Expand all
10166 UNREACHABLE(); 10214 UNREACHABLE();
10167 } 10215 }
10168 } 10216 }
10169 10217
10170 10218
10171 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( 10219 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray(
10172 Handle<FixedArrayBase> elements, 10220 Handle<FixedArrayBase> elements,
10173 ElementsKind kind, 10221 ElementsKind kind,
10174 HValue* object_elements) { 10222 HValue* object_elements) {
10175 Zone* zone = this->zone(); 10223 Zone* zone = this->zone();
10176 HInstruction* boilerplate_elements = 10224 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant(
10177 AddInstruction(new(zone) HConstant(elements)); 10225 elements, Representation::Tagged()));
10178 int elements_length = elements->length(); 10226 int elements_length = elements->length();
10179 for (int i = 0; i < elements_length; i++) { 10227 for (int i = 0; i < elements_length; i++) {
10180 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); 10228 HValue* key_constant = AddInstruction(new(zone) HConstant(i));
10181 HInstruction* value_instruction = 10229 HInstruction* value_instruction =
10182 AddInstruction(new(zone) HLoadKeyed( 10230 AddInstruction(new(zone) HLoadKeyed(
10183 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE)); 10231 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE));
10184 HInstruction* store = AddInstruction(new(zone) HStoreKeyed( 10232 HInstruction* store = AddInstruction(new(zone) HStoreKeyed(
10185 object_elements, key_constant, value_instruction, kind)); 10233 object_elements, key_constant, value_instruction, kind));
10186 store->SetFlag(HValue::kAllowUndefinedAsNaN); 10234 store->SetFlag(HValue::kAllowUndefinedAsNaN);
10187 } 10235 }
10188 } 10236 }
10189 10237
10190 10238
10191 void HOptimizedGraphBuilder::BuildEmitFixedArray( 10239 void HOptimizedGraphBuilder::BuildEmitFixedArray(
10192 Handle<FixedArrayBase> elements, 10240 Handle<FixedArrayBase> elements,
10193 Handle<FixedArrayBase> original_elements, 10241 Handle<FixedArrayBase> original_elements,
10194 ElementsKind kind, 10242 ElementsKind kind,
10195 HValue* object_elements, 10243 HValue* object_elements,
10196 HInstruction* target, 10244 HInstruction* target,
10197 int* offset) { 10245 int* offset) {
10198 Zone* zone = this->zone(); 10246 Zone* zone = this->zone();
10199 HInstruction* boilerplate_elements = 10247 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant(
10200 AddInstruction(new(zone) HConstant(elements)); 10248 elements, Representation::Tagged()));
10201 int elements_length = elements->length(); 10249 int elements_length = elements->length();
10202 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 10250 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
10203 Handle<FixedArray> original_fast_elements = 10251 Handle<FixedArray> original_fast_elements =
10204 Handle<FixedArray>::cast(original_elements); 10252 Handle<FixedArray>::cast(original_elements);
10205 for (int i = 0; i < elements_length; i++) { 10253 for (int i = 0; i < elements_length; i++) {
10206 Handle<Object> value(fast_elements->get(i), isolate()); 10254 Handle<Object> value(fast_elements->get(i), isolate());
10207 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); 10255 HValue* key_constant = AddInstruction(new(zone) HConstant(i));
10208 if (value->IsJSObject()) { 10256 if (value->IsJSObject()) {
10209 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 10257 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
10210 Handle<JSObject> original_value_object = Handle<JSObject>::cast( 10258 Handle<JSObject> original_value_object = Handle<JSObject>::cast(
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
10959 11007
10960 HEnvironment::HEnvironment(HEnvironment* outer, 11008 HEnvironment::HEnvironment(HEnvironment* outer,
10961 Handle<JSFunction> closure, 11009 Handle<JSFunction> closure,
10962 FrameType frame_type, 11010 FrameType frame_type,
10963 int arguments, 11011 int arguments,
10964 Zone* zone) 11012 Zone* zone)
10965 : closure_(closure), 11013 : closure_(closure),
10966 values_(arguments, zone), 11014 values_(arguments, zone),
10967 frame_type_(frame_type), 11015 frame_type_(frame_type),
10968 parameter_count_(arguments), 11016 parameter_count_(arguments),
10969 specials_count_(0),
10970 local_count_(0), 11017 local_count_(0),
10971 outer_(outer), 11018 outer_(outer),
10972 entry_(NULL), 11019 entry_(NULL),
10973 pop_count_(0), 11020 pop_count_(0),
10974 push_count_(0), 11021 push_count_(0),
10975 ast_id_(BailoutId::None()), 11022 ast_id_(BailoutId::None()),
10976 zone_(zone) { 11023 zone_(zone) {
10977 } 11024 }
10978 11025
10979 11026
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
11575 } 11622 }
11576 } 11623 }
11577 11624
11578 #ifdef DEBUG 11625 #ifdef DEBUG
11579 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11626 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11580 if (allocator_ != NULL) allocator_->Verify(); 11627 if (allocator_ != NULL) allocator_->Verify();
11581 #endif 11628 #endif
11582 } 11629 }
11583 11630
11584 } } // namespace v8::internal 11631 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698