OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length); | 997 HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length); |
998 AddInstruction(result); | 998 AddInstruction(result); |
999 return result; | 999 return result; |
1000 } | 1000 } |
1001 | 1001 |
1002 | 1002 |
1003 HReturn* HGraphBuilder::AddReturn(HValue* value) { | 1003 HReturn* HGraphBuilder::AddReturn(HValue* value) { |
1004 HValue* context = environment()->LookupContext(); | 1004 HValue* context = environment()->LookupContext(); |
1005 int num_parameters = graph()->info()->num_parameters(); | 1005 int num_parameters = graph()->info()->num_parameters(); |
1006 HValue* params = AddInstruction(new(graph()->zone()) | 1006 HValue* params = AddInstruction(new(graph()->zone()) |
1007 HConstant(num_parameters, Representation::Integer32())); | 1007 HConstant(num_parameters)); |
1008 HReturn* return_instruction = new(graph()->zone()) | 1008 HReturn* return_instruction = new(graph()->zone()) |
1009 HReturn(value, context, params); | 1009 HReturn(value, context, params); |
1010 current_block()->FinishExit(return_instruction); | 1010 current_block()->FinishExit(return_instruction); |
1011 return return_instruction; | 1011 return return_instruction; |
1012 } | 1012 } |
1013 | 1013 |
1014 | 1014 |
1015 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { | 1015 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { |
1016 HBasicBlock* b = graph()->CreateBasicBlock(); | 1016 HBasicBlock* b = graph()->CreateBasicBlock(); |
1017 b->SetInitialEnvironment(env); | 1017 b->SetInitialEnvironment(env); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 } | 1335 } |
1336 | 1336 |
1337 | 1337 |
1338 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, | 1338 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
1339 ElementsKind kind, | 1339 ElementsKind kind, |
1340 HValue* capacity) { | 1340 HValue* capacity) { |
1341 Zone* zone = this->zone(); | 1341 Zone* zone = this->zone(); |
1342 | 1342 |
1343 int elements_size = IsFastDoubleElementsKind(kind) | 1343 int elements_size = IsFastDoubleElementsKind(kind) |
1344 ? kDoubleSize : kPointerSize; | 1344 ? kDoubleSize : kPointerSize; |
1345 HConstant* elements_size_value = | 1345 HConstant* elements_size_value = new(zone) HConstant(elements_size); |
1346 new(zone) HConstant(elements_size, Representation::Integer32()); | |
1347 AddInstruction(elements_size_value); | 1346 AddInstruction(elements_size_value); |
1348 HValue* mul = AddInstruction( | 1347 HValue* mul = AddInstruction( |
1349 HMul::New(zone, context, capacity, elements_size_value)); | 1348 HMul::New(zone, context, capacity, elements_size_value)); |
1350 mul->AssumeRepresentation(Representation::Integer32()); | 1349 mul->AssumeRepresentation(Representation::Integer32()); |
1351 mul->ClearFlag(HValue::kCanOverflow); | 1350 mul->ClearFlag(HValue::kCanOverflow); |
1352 | 1351 |
1353 HConstant* header_size = | 1352 HConstant* header_size = new(zone) HConstant(FixedArray::kHeaderSize); |
1354 new(zone) HConstant(FixedArray::kHeaderSize, Representation::Integer32()); | |
1355 AddInstruction(header_size); | 1353 AddInstruction(header_size); |
1356 HValue* total_size = AddInstruction( | 1354 HValue* total_size = AddInstruction( |
1357 HAdd::New(zone, context, mul, header_size)); | 1355 HAdd::New(zone, context, mul, header_size)); |
1358 total_size->AssumeRepresentation(Representation::Integer32()); | 1356 total_size->AssumeRepresentation(Representation::Integer32()); |
1359 total_size->ClearFlag(HValue::kCanOverflow); | 1357 total_size->ClearFlag(HValue::kCanOverflow); |
1360 | 1358 |
1361 HAllocate::Flags flags = HAllocate::DefaultFlags(kind); | 1359 HAllocate::Flags flags = HAllocate::DefaultFlags(kind); |
1362 if (isolate()->heap()->ShouldGloballyPretenure()) { | 1360 if (isolate()->heap()->ShouldGloballyPretenure()) { |
1363 // TODO(hpayer): When pretenuring can be internalized, flags can become | 1361 // TODO(hpayer): When pretenuring can be internalized, flags can become |
1364 // private to HAllocate. | 1362 // private to HAllocate. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 | 1404 |
1407 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, | 1405 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
1408 HValue* array_map, | 1406 HValue* array_map, |
1409 AllocationSiteMode mode, | 1407 AllocationSiteMode mode, |
1410 HValue* allocation_site_payload, | 1408 HValue* allocation_site_payload, |
1411 HValue* length_field) { | 1409 HValue* length_field) { |
1412 | 1410 |
1413 AddStore(array, HObjectAccess::ForMap(), array_map); | 1411 AddStore(array, HObjectAccess::ForMap(), array_map); |
1414 | 1412 |
1415 HConstant* empty_fixed_array = | 1413 HConstant* empty_fixed_array = |
1416 new(zone()) HConstant( | 1414 new(zone()) HConstant(isolate()->factory()->empty_fixed_array()); |
1417 Handle<FixedArray>(isolate()->heap()->empty_fixed_array()), | |
1418 Representation::Tagged()); | |
1419 AddInstruction(empty_fixed_array); | 1415 AddInstruction(empty_fixed_array); |
1420 | 1416 |
1421 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 1417 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
1422 AddStore(array, access, empty_fixed_array); | 1418 AddStore(array, access, empty_fixed_array); |
1423 AddStore(array, HObjectAccess::ForArrayLength(), length_field); | 1419 AddStore(array, HObjectAccess::ForArrayLength(), length_field); |
1424 | 1420 |
1425 if (mode == TRACK_ALLOCATION_SITE) { | 1421 if (mode == TRACK_ALLOCATION_SITE) { |
1426 BuildCreateAllocationSiteInfo(array, | 1422 BuildCreateAllocationSiteInfo(array, |
1427 JSArray::kSize, | 1423 JSArray::kSize, |
1428 allocation_site_payload); | 1424 allocation_site_payload); |
(...skipping 26 matching lines...) Expand all Loading... |
1455 AddInstruction(HShr::New(zone, context, old_capacity, | 1451 AddInstruction(HShr::New(zone, context, old_capacity, |
1456 graph_->GetConstant1())); | 1452 graph_->GetConstant1())); |
1457 half_old_capacity->AssumeRepresentation(Representation::Integer32()); | 1453 half_old_capacity->AssumeRepresentation(Representation::Integer32()); |
1458 half_old_capacity->ClearFlag(HValue::kCanOverflow); | 1454 half_old_capacity->ClearFlag(HValue::kCanOverflow); |
1459 | 1455 |
1460 HValue* new_capacity = AddInstruction( | 1456 HValue* new_capacity = AddInstruction( |
1461 HAdd::New(zone, context, half_old_capacity, old_capacity)); | 1457 HAdd::New(zone, context, half_old_capacity, old_capacity)); |
1462 new_capacity->AssumeRepresentation(Representation::Integer32()); | 1458 new_capacity->AssumeRepresentation(Representation::Integer32()); |
1463 new_capacity->ClearFlag(HValue::kCanOverflow); | 1459 new_capacity->ClearFlag(HValue::kCanOverflow); |
1464 | 1460 |
1465 HValue* min_growth = | 1461 HValue* min_growth = AddInstruction(new(zone) HConstant(16)); |
1466 AddInstruction(new(zone) HConstant(16, Representation::Integer32())); | |
1467 | 1462 |
1468 new_capacity = AddInstruction( | 1463 new_capacity = AddInstruction( |
1469 HAdd::New(zone, context, new_capacity, min_growth)); | 1464 HAdd::New(zone, context, new_capacity, min_growth)); |
1470 new_capacity->AssumeRepresentation(Representation::Integer32()); | 1465 new_capacity->AssumeRepresentation(Representation::Integer32()); |
1471 new_capacity->ClearFlag(HValue::kCanOverflow); | 1466 new_capacity->ClearFlag(HValue::kCanOverflow); |
1472 | 1467 |
1473 return new_capacity; | 1468 return new_capacity; |
1474 } | 1469 } |
1475 | 1470 |
1476 | 1471 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 ElementsKind elements_kind, | 1511 ElementsKind elements_kind, |
1517 HValue* from, | 1512 HValue* from, |
1518 HValue* to) { | 1513 HValue* to) { |
1519 // Fast elements kinds need to be initialized in case statements below cause | 1514 // Fast elements kinds need to be initialized in case statements below cause |
1520 // a garbage collection. | 1515 // a garbage collection. |
1521 Factory* factory = isolate()->factory(); | 1516 Factory* factory = isolate()->factory(); |
1522 | 1517 |
1523 double nan_double = FixedDoubleArray::hole_nan_as_double(); | 1518 double nan_double = FixedDoubleArray::hole_nan_as_double(); |
1524 Zone* zone = this->zone(); | 1519 Zone* zone = this->zone(); |
1525 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) | 1520 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) |
1526 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(), | 1521 ? AddInstruction(new(zone) HConstant(factory->the_hole_value())) |
1527 Representation::Tagged())) | 1522 : AddInstruction(new(zone) HConstant(nan_double)); |
1528 : AddInstruction(new(zone) HConstant(nan_double, | |
1529 Representation::Double())); | |
1530 | 1523 |
1531 // Special loop unfolding case | 1524 // Special loop unfolding case |
1532 static const int kLoopUnfoldLimit = 4; | 1525 static const int kLoopUnfoldLimit = 4; |
1533 bool unfold_loop = false; | 1526 bool unfold_loop = false; |
1534 int initial_capacity = JSArray::kPreallocatedArrayElements; | 1527 int initial_capacity = JSArray::kPreallocatedArrayElements; |
1535 if (from->IsConstant() && to->IsConstant() && | 1528 if (from->IsConstant() && to->IsConstant() && |
1536 initial_capacity <= kLoopUnfoldLimit) { | 1529 initial_capacity <= kLoopUnfoldLimit) { |
1537 HConstant* constant_from = HConstant::cast(from); | 1530 HConstant* constant_from = HConstant::cast(from); |
1538 HConstant* constant_to = HConstant::cast(to); | 1531 HConstant* constant_to = HConstant::cast(to); |
1539 | 1532 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 int elems_offset = size; | 1625 int elems_offset = size; |
1633 if (length > 0) { | 1626 if (length > 0) { |
1634 size += IsFastDoubleElementsKind(kind) | 1627 size += IsFastDoubleElementsKind(kind) |
1635 ? FixedDoubleArray::SizeFor(length) | 1628 ? FixedDoubleArray::SizeFor(length) |
1636 : FixedArray::SizeFor(length); | 1629 : FixedArray::SizeFor(length); |
1637 } | 1630 } |
1638 | 1631 |
1639 HAllocate::Flags allocate_flags = HAllocate::DefaultFlags(kind); | 1632 HAllocate::Flags allocate_flags = HAllocate::DefaultFlags(kind); |
1640 // Allocate both the JS array and the elements array in one big | 1633 // Allocate both the JS array and the elements array in one big |
1641 // allocation. This avoids multiple limit checks. | 1634 // allocation. This avoids multiple limit checks. |
1642 HValue* size_in_bytes = | 1635 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size)); |
1643 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); | |
1644 HInstruction* object = | 1636 HInstruction* object = |
1645 AddInstruction(new(zone) HAllocate(context, | 1637 AddInstruction(new(zone) HAllocate(context, |
1646 size_in_bytes, | 1638 size_in_bytes, |
1647 HType::JSObject(), | 1639 HType::JSObject(), |
1648 allocate_flags)); | 1640 allocate_flags)); |
1649 | 1641 |
1650 // Copy the JS array part. | 1642 // Copy the JS array part. |
1651 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 1643 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
1652 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 1644 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
1653 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 1645 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 HGlobalObject(context)); | 1748 HGlobalObject(context)); |
1757 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 1749 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
1758 GlobalObject::kNativeContextOffset); | 1750 GlobalObject::kNativeContextOffset); |
1759 return AddLoad(global_object, access); | 1751 return AddLoad(global_object, access); |
1760 } | 1752 } |
1761 | 1753 |
1762 | 1754 |
1763 HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) { | 1755 HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) { |
1764 HInstruction* native_context = BuildGetNativeContext(context); | 1756 HInstruction* native_context = BuildGetNativeContext(context); |
1765 HInstruction* index = AddInstruction(new(zone()) | 1757 HInstruction* index = AddInstruction(new(zone()) |
1766 HConstant(Context::ARRAY_FUNCTION_INDEX, Representation::Integer32())); | 1758 HConstant(Context::ARRAY_FUNCTION_INDEX)); |
1767 | 1759 |
1768 return AddInstruction(new (zone()) | 1760 return AddInstruction(new (zone()) |
1769 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); | 1761 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); |
1770 } | 1762 } |
1771 | 1763 |
1772 | 1764 |
1773 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1765 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1774 ElementsKind kind, | 1766 ElementsKind kind, |
1775 HValue* allocation_site_payload, | 1767 HValue* allocation_site_payload, |
1776 bool disable_allocation_sites) : | 1768 bool disable_allocation_sites) : |
(...skipping 15 matching lines...) Expand all Loading... |
1792 mode_(DONT_TRACK_ALLOCATION_SITE), | 1784 mode_(DONT_TRACK_ALLOCATION_SITE), |
1793 allocation_site_payload_(NULL), | 1785 allocation_site_payload_(NULL), |
1794 constructor_function_(constructor_function) { | 1786 constructor_function_(constructor_function) { |
1795 } | 1787 } |
1796 | 1788 |
1797 | 1789 |
1798 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { | 1790 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
1799 HInstruction* native_context = builder()->BuildGetNativeContext(context); | 1791 HInstruction* native_context = builder()->BuildGetNativeContext(context); |
1800 | 1792 |
1801 HInstruction* index = builder()->AddInstruction(new(zone()) | 1793 HInstruction* index = builder()->AddInstruction(new(zone()) |
1802 HConstant(Context::JS_ARRAY_MAPS_INDEX, Representation::Integer32())); | 1794 HConstant(Context::JS_ARRAY_MAPS_INDEX)); |
1803 | 1795 |
1804 HInstruction* map_array = builder()->AddInstruction(new(zone()) | 1796 HInstruction* map_array = builder()->AddInstruction(new(zone()) |
1805 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); | 1797 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); |
1806 | 1798 |
1807 HInstruction* kind_index = builder()->AddInstruction(new(zone()) | 1799 HInstruction* kind_index = builder()->AddInstruction(new(zone()) |
1808 HConstant(kind_, Representation::Integer32())); | 1800 HConstant(kind_)); |
1809 | 1801 |
1810 return builder()->AddInstruction(new(zone()) | 1802 return builder()->AddInstruction(new(zone()) |
1811 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); | 1803 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); |
1812 } | 1804 } |
1813 | 1805 |
1814 | 1806 |
1815 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { | 1807 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { |
1816 // Find the map near the constructor function | 1808 // Find the map near the constructor function |
1817 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); | 1809 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); |
1818 return AddInstruction( | 1810 return AddInstruction( |
(...skipping 12 matching lines...) Expand all Loading... |
1831 if (mode_ == TRACK_ALLOCATION_SITE) { | 1823 if (mode_ == TRACK_ALLOCATION_SITE) { |
1832 base_size += AllocationSiteInfo::kSize; | 1824 base_size += AllocationSiteInfo::kSize; |
1833 } | 1825 } |
1834 | 1826 |
1835 if (IsFastDoubleElementsKind(kind_)) { | 1827 if (IsFastDoubleElementsKind(kind_)) { |
1836 base_size += FixedDoubleArray::kHeaderSize; | 1828 base_size += FixedDoubleArray::kHeaderSize; |
1837 } else { | 1829 } else { |
1838 base_size += FixedArray::kHeaderSize; | 1830 base_size += FixedArray::kHeaderSize; |
1839 } | 1831 } |
1840 | 1832 |
1841 HInstruction* elements_size_value = new(zone()) | 1833 HInstruction* elements_size_value = new(zone()) HConstant(elements_size()); |
1842 HConstant(elements_size(), Representation::Integer32()); | |
1843 AddInstruction(elements_size_value); | 1834 AddInstruction(elements_size_value); |
1844 HInstruction* mul = HMul::New(zone(), context, length_node, | 1835 HInstruction* mul = HMul::New(zone(), context, length_node, |
1845 elements_size_value); | 1836 elements_size_value); |
1846 mul->AssumeRepresentation(Representation::Integer32()); | 1837 mul->AssumeRepresentation(Representation::Integer32()); |
1847 mul->ClearFlag(HValue::kCanOverflow); | 1838 mul->ClearFlag(HValue::kCanOverflow); |
1848 AddInstruction(mul); | 1839 AddInstruction(mul); |
1849 | 1840 |
1850 HInstruction* base = new(zone()) HConstant(base_size, | 1841 HInstruction* base = new(zone()) HConstant(base_size); |
1851 Representation::Integer32()); | |
1852 AddInstruction(base); | 1842 AddInstruction(base); |
1853 HInstruction* total_size = HAdd::New(zone(), context, base, mul); | 1843 HInstruction* total_size = HAdd::New(zone(), context, base, mul); |
1854 total_size->AssumeRepresentation(Representation::Integer32()); | 1844 total_size->AssumeRepresentation(Representation::Integer32()); |
1855 total_size->ClearFlag(HValue::kCanOverflow); | 1845 total_size->ClearFlag(HValue::kCanOverflow); |
1856 AddInstruction(total_size); | 1846 AddInstruction(total_size); |
1857 return total_size; | 1847 return total_size; |
1858 } | 1848 } |
1859 | 1849 |
1860 | 1850 |
1861 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { | 1851 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { |
1862 int base_size = JSArray::kSize; | 1852 int base_size = JSArray::kSize; |
1863 if (mode_ == TRACK_ALLOCATION_SITE) { | 1853 if (mode_ == TRACK_ALLOCATION_SITE) { |
1864 base_size += AllocationSiteInfo::kSize; | 1854 base_size += AllocationSiteInfo::kSize; |
1865 } | 1855 } |
1866 | 1856 |
1867 base_size += IsFastDoubleElementsKind(kind_) | 1857 base_size += IsFastDoubleElementsKind(kind_) |
1868 ? FixedDoubleArray::SizeFor(initial_capacity()) | 1858 ? FixedDoubleArray::SizeFor(initial_capacity()) |
1869 : FixedArray::SizeFor(initial_capacity()); | 1859 : FixedArray::SizeFor(initial_capacity()); |
1870 | 1860 |
1871 HConstant* array_size = | 1861 HConstant* array_size = new(zone()) HConstant(base_size); |
1872 new(zone()) HConstant(base_size, Representation::Integer32()); | |
1873 AddInstruction(array_size); | 1862 AddInstruction(array_size); |
1874 return array_size; | 1863 return array_size; |
1875 } | 1864 } |
1876 | 1865 |
1877 | 1866 |
1878 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { | 1867 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { |
1879 HValue* size_in_bytes = EstablishEmptyArrayAllocationSize(); | 1868 HValue* size_in_bytes = EstablishEmptyArrayAllocationSize(); |
1880 HConstant* capacity = | 1869 HConstant* capacity = new(zone()) HConstant(initial_capacity()); |
1881 new(zone()) HConstant(initial_capacity(), Representation::Integer32()); | |
1882 AddInstruction(capacity); | 1870 AddInstruction(capacity); |
1883 return AllocateArray(size_in_bytes, | 1871 return AllocateArray(size_in_bytes, |
1884 capacity, | 1872 capacity, |
1885 builder()->graph()->GetConstant0(), | 1873 builder()->graph()->GetConstant0(), |
1886 true); | 1874 true); |
1887 } | 1875 } |
1888 | 1876 |
1889 | 1877 |
1890 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity, | 1878 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity, |
1891 HValue* length_field, | 1879 HValue* length_field, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 Representation representation) { | 1937 Representation representation) { |
1950 HLoadNamedField *instr = | 1938 HLoadNamedField *instr = |
1951 new(zone()) HLoadNamedField(object, access, typecheck, representation); | 1939 new(zone()) HLoadNamedField(object, access, typecheck, representation); |
1952 AddInstruction(instr); | 1940 AddInstruction(instr); |
1953 return instr; | 1941 return instr; |
1954 } | 1942 } |
1955 | 1943 |
1956 | 1944 |
1957 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, | 1945 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, |
1958 Handle<Map> map) { | 1946 Handle<Map> map) { |
1959 HValue* constant = | 1947 HValue* constant = AddInstruction(new(zone()) HConstant(map)); |
1960 AddInstruction(new(zone()) HConstant(map, Representation::Tagged())); | |
1961 HStoreNamedField *instr = | 1948 HStoreNamedField *instr = |
1962 new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(), constant); | 1949 new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(), constant); |
1963 AddInstruction(instr); | 1950 AddInstruction(instr); |
1964 return instr; | 1951 return instr; |
1965 } | 1952 } |
1966 | 1953 |
1967 | 1954 |
1968 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) | 1955 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) |
1969 : HGraphBuilder(info), | 1956 : HGraphBuilder(info), |
1970 function_state_(NULL), | 1957 function_state_(NULL), |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4687 | 4674 |
4688 while (!arguments.is_empty()) { | 4675 while (!arguments.is_empty()) { |
4689 AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast())); | 4676 AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast())); |
4690 } | 4677 } |
4691 return call; | 4678 return call; |
4692 } | 4679 } |
4693 | 4680 |
4694 | 4681 |
4695 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) { | 4682 void HOptimizedGraphBuilder::SetUpScope(Scope* scope) { |
4696 HConstant* undefined_constant = new(zone()) HConstant( | 4683 HConstant* undefined_constant = new(zone()) HConstant( |
4697 isolate()->factory()->undefined_value(), Representation::Tagged()); | 4684 isolate()->factory()->undefined_value()); |
4698 AddInstruction(undefined_constant); | 4685 AddInstruction(undefined_constant); |
4699 graph()->set_undefined_constant(undefined_constant); | 4686 graph()->set_undefined_constant(undefined_constant); |
4700 | 4687 |
4701 // Create an arguments object containing the initial parameters. Set the | 4688 // Create an arguments object containing the initial parameters. Set the |
4702 // initial values of parameters including "this" having parameter index 0. | 4689 // initial values of parameters including "this" having parameter index 0. |
4703 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); | 4690 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); |
4704 HArgumentsObject* arguments_object = | 4691 HArgumentsObject* arguments_object = |
4705 new(zone()) HArgumentsObject(environment()->parameter_count(), zone()); | 4692 new(zone()) HArgumentsObject(environment()->parameter_count(), zone()); |
4706 for (int i = 0; i < environment()->parameter_count(); ++i) { | 4693 for (int i = 0; i < environment()->parameter_count(); ++i) { |
4707 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i)); | 4694 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i)); |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5613 case Variable::UNALLOCATED: { | 5600 case Variable::UNALLOCATED: { |
5614 if (IsLexicalVariableMode(variable->mode())) { | 5601 if (IsLexicalVariableMode(variable->mode())) { |
5615 // TODO(rossberg): should this be an ASSERT? | 5602 // TODO(rossberg): should this be an ASSERT? |
5616 return Bailout("reference to global lexical variable"); | 5603 return Bailout("reference to global lexical variable"); |
5617 } | 5604 } |
5618 // Handle known global constants like 'undefined' specially to avoid a | 5605 // Handle known global constants like 'undefined' specially to avoid a |
5619 // load from a global cell for them. | 5606 // load from a global cell for them. |
5620 Handle<Object> constant_value = | 5607 Handle<Object> constant_value = |
5621 isolate()->factory()->GlobalConstantFor(variable->name()); | 5608 isolate()->factory()->GlobalConstantFor(variable->name()); |
5622 if (!constant_value.is_null()) { | 5609 if (!constant_value.is_null()) { |
5623 HConstant* instr = | 5610 HConstant* instr = new(zone()) HConstant(constant_value); |
5624 new(zone()) HConstant(constant_value, Representation::Tagged()); | |
5625 return ast_context()->ReturnInstruction(instr, expr->id()); | 5611 return ast_context()->ReturnInstruction(instr, expr->id()); |
5626 } | 5612 } |
5627 | 5613 |
5628 LookupResult lookup(isolate()); | 5614 LookupResult lookup(isolate()); |
5629 GlobalPropertyAccess type = | 5615 GlobalPropertyAccess type = |
5630 LookupGlobalProperty(variable, &lookup, false); | 5616 LookupGlobalProperty(variable, &lookup, false); |
5631 | 5617 |
5632 if (type == kUseCell && | 5618 if (type == kUseCell && |
5633 current_info()->global_object()->IsAccessCheckNeeded()) { | 5619 current_info()->global_object()->IsAccessCheckNeeded()) { |
5634 type = kUseGeneric; | 5620 type = kUseGeneric; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5674 case Variable::LOOKUP: | 5660 case Variable::LOOKUP: |
5675 return Bailout("reference to a variable which requires dynamic lookup"); | 5661 return Bailout("reference to a variable which requires dynamic lookup"); |
5676 } | 5662 } |
5677 } | 5663 } |
5678 | 5664 |
5679 | 5665 |
5680 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { | 5666 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { |
5681 ASSERT(!HasStackOverflow()); | 5667 ASSERT(!HasStackOverflow()); |
5682 ASSERT(current_block() != NULL); | 5668 ASSERT(current_block() != NULL); |
5683 ASSERT(current_block()->HasPredecessor()); | 5669 ASSERT(current_block()->HasPredecessor()); |
5684 HConstant* instr = | 5670 HConstant* instr = new(zone()) HConstant(expr->handle()); |
5685 new(zone()) HConstant(expr->handle(), Representation::None()); | |
5686 return ast_context()->ReturnInstruction(instr, expr->id()); | 5671 return ast_context()->ReturnInstruction(instr, expr->id()); |
5687 } | 5672 } |
5688 | 5673 |
5689 | 5674 |
5690 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { | 5675 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { |
5691 ASSERT(!HasStackOverflow()); | 5676 ASSERT(!HasStackOverflow()); |
5692 ASSERT(current_block() != NULL); | 5677 ASSERT(current_block() != NULL); |
5693 ASSERT(current_block()->HasPredecessor()); | 5678 ASSERT(current_block()->HasPredecessor()); |
5694 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); | 5679 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); |
5695 Handle<FixedArray> literals(closure->literals()); | 5680 Handle<FixedArray> literals(closure->literals()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5900 NoObservableSideEffectsScope no_effects(this); | 5885 NoObservableSideEffectsScope no_effects(this); |
5901 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5886 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
5902 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5887 Handle<FixedArray> constant_properties = expr->constant_properties(); |
5903 int literal_index = expr->literal_index(); | 5888 int literal_index = expr->literal_index(); |
5904 int flags = expr->fast_elements() | 5889 int flags = expr->fast_elements() |
5905 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; | 5890 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; |
5906 flags |= expr->has_function() | 5891 flags |= expr->has_function() |
5907 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; | 5892 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; |
5908 | 5893 |
5909 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 5894 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
5910 new(zone()) HConstant(closure_literals, Representation::Tagged())))); | 5895 new(zone()) HConstant(closure_literals)))); |
5911 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 5896 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
5912 new(zone()) HConstant(literal_index, Representation::Tagged())))); | 5897 new(zone()) HConstant(literal_index)))); |
5913 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 5898 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
5914 new(zone()) HConstant(constant_properties, Representation::Tagged())))); | 5899 new(zone()) HConstant(constant_properties)))); |
5915 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 5900 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
5916 new(zone()) HConstant(flags, Representation::Tagged())))); | 5901 new(zone()) HConstant(flags)))); |
5917 | 5902 |
5918 Runtime::FunctionId function_id = | 5903 Runtime::FunctionId function_id = |
5919 (expr->depth() > 1 || expr->may_store_doubles()) | 5904 (expr->depth() > 1 || expr->may_store_doubles()) |
5920 ? Runtime::kCreateObjectLiteral : Runtime::kCreateObjectLiteralShallow; | 5905 ? Runtime::kCreateObjectLiteral : Runtime::kCreateObjectLiteralShallow; |
5921 literal = AddInstruction( | 5906 literal = AddInstruction( |
5922 new(zone()) HCallRuntime(context, | 5907 new(zone()) HCallRuntime(context, |
5923 isolate()->factory()->empty_string(), | 5908 isolate()->factory()->empty_string(), |
5924 Runtime::FunctionForId(function_id), | 5909 Runtime::FunctionForId(function_id), |
5925 4)); | 5910 4)); |
5926 } | 5911 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6064 // TODO(mstarzinger): The following check and deopt is actually obsolete | 6049 // TODO(mstarzinger): The following check and deopt is actually obsolete |
6065 // but test cases for the tick processor fails because profile differs. | 6050 // but test cases for the tick processor fails because profile differs. |
6066 | 6051 |
6067 // Deopt if the array literal boilerplate ElementsKind is of a type | 6052 // Deopt if the array literal boilerplate ElementsKind is of a type |
6068 // different than the expected one. The check isn't necessary if the | 6053 // different than the expected one. The check isn't necessary if the |
6069 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 6054 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
6070 if (CanTransitionToMoreGeneralFastElementsKind( | 6055 if (CanTransitionToMoreGeneralFastElementsKind( |
6071 boilerplate_elements_kind, true)) { | 6056 boilerplate_elements_kind, true)) { |
6072 IfBuilder builder(this); | 6057 IfBuilder builder(this); |
6073 HValue* boilerplate = AddInstruction(new(zone()) | 6058 HValue* boilerplate = AddInstruction(new(zone()) |
6074 HConstant(original_boilerplate_object, Representation::Tagged())); | 6059 HConstant(original_boilerplate_object)); |
6075 HValue* elements_kind = AddInstruction(new(zone()) | 6060 HValue* elements_kind = AddInstruction(new(zone()) |
6076 HElementsKind(boilerplate)); | 6061 HElementsKind(boilerplate)); |
6077 HValue* expected_kind = AddInstruction(new(zone()) | 6062 HValue* expected_kind = AddInstruction(new(zone()) |
6078 HConstant(boilerplate_elements_kind, Representation::Integer32())); | 6063 HConstant(boilerplate_elements_kind)); |
6079 builder.IfCompare(elements_kind, expected_kind, Token::EQ); | 6064 builder.IfCompare(elements_kind, expected_kind, Token::EQ); |
6080 builder.Then(); | 6065 builder.Then(); |
6081 builder.ElseDeopt(); | 6066 builder.ElseDeopt(); |
6082 } | 6067 } |
6083 | 6068 |
6084 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 6069 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
6085 new(zone()) HConstant(literals, Representation::Tagged())))); | 6070 new(zone()) HConstant(literals)))); |
6086 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 6071 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
6087 new(zone()) HConstant(literal_index, Representation::Tagged())))); | 6072 new(zone()) HConstant(literal_index)))); |
6088 AddInstruction(new(zone()) HPushArgument(AddInstruction( | 6073 AddInstruction(new(zone()) HPushArgument(AddInstruction( |
6089 new(zone()) HConstant(constants, Representation::Tagged())))); | 6074 new(zone()) HConstant(constants)))); |
6090 | 6075 |
6091 Runtime::FunctionId function_id = (expr->depth() > 1) | 6076 Runtime::FunctionId function_id = (expr->depth() > 1) |
6092 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; | 6077 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; |
6093 literal = AddInstruction( | 6078 literal = AddInstruction( |
6094 new(zone()) HCallRuntime(context, | 6079 new(zone()) HCallRuntime(context, |
6095 isolate()->factory()->empty_string(), | 6080 isolate()->factory()->empty_string(), |
6096 Runtime::FunctionForId(function_id), | 6081 Runtime::FunctionForId(function_id), |
6097 3)); | 6082 3)); |
6098 } | 6083 } |
6099 | 6084 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6233 HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name); | 6218 HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name); |
6234 Representation representation = ComputeLoadStoreRepresentation(map, lookup); | 6219 Representation representation = ComputeLoadStoreRepresentation(map, lookup); |
6235 bool transition_to_field = lookup->IsTransitionToField(*map); | 6220 bool transition_to_field = lookup->IsTransitionToField(*map); |
6236 | 6221 |
6237 HStoreNamedField *instr; | 6222 HStoreNamedField *instr; |
6238 if (FLAG_track_double_fields && representation.IsDouble()) { | 6223 if (FLAG_track_double_fields && representation.IsDouble()) { |
6239 if (transition_to_field) { | 6224 if (transition_to_field) { |
6240 // The store requires a mutable HeapNumber to be allocated. | 6225 // The store requires a mutable HeapNumber to be allocated. |
6241 NoObservableSideEffectsScope no_side_effects(this); | 6226 NoObservableSideEffectsScope no_side_effects(this); |
6242 HInstruction* heap_number_size = AddInstruction(new(zone()) HConstant( | 6227 HInstruction* heap_number_size = AddInstruction(new(zone()) HConstant( |
6243 HeapNumber::kSize, Representation::Integer32())); | 6228 HeapNumber::kSize)); |
6244 HInstruction* double_box = AddInstruction(new(zone()) HAllocate( | 6229 HInstruction* double_box = AddInstruction(new(zone()) HAllocate( |
6245 environment()->LookupContext(), heap_number_size, | 6230 environment()->LookupContext(), heap_number_size, |
6246 HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE)); | 6231 HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE)); |
6247 AddStoreMapConstant(double_box, isolate()->factory()->heap_number_map()); | 6232 AddStoreMapConstant(double_box, isolate()->factory()->heap_number_map()); |
6248 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), | 6233 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), |
6249 value, Representation::Double()); | 6234 value, Representation::Double()); |
6250 instr = new(zone()) HStoreNamedField(object, field_access, double_box); | 6235 instr = new(zone()) HStoreNamedField(object, field_access, double_box); |
6251 } else { | 6236 } else { |
6252 // Already holds a HeapNumber; load the box and write its value field. | 6237 // Already holds a HeapNumber; load the box and write its value field. |
6253 HInstruction* double_box = AddLoad(object, field_access); | 6238 HInstruction* double_box = AddLoad(object, field_access); |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6994 AddCheckMap(object, map); | 6979 AddCheckMap(object, map); |
6995 return BuildLoadNamedField(object, | 6980 return BuildLoadNamedField(object, |
6996 HObjectAccess::ForField(map, &lookup, name), | 6981 HObjectAccess::ForField(map, &lookup, name), |
6997 ComputeLoadStoreRepresentation(map, &lookup)); | 6982 ComputeLoadStoreRepresentation(map, &lookup)); |
6998 } | 6983 } |
6999 | 6984 |
7000 // Handle a load of a constant known function. | 6985 // Handle a load of a constant known function. |
7001 if (lookup.IsConstantFunction()) { | 6986 if (lookup.IsConstantFunction()) { |
7002 AddCheckMap(object, map); | 6987 AddCheckMap(object, map); |
7003 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); | 6988 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); |
7004 return new(zone()) HConstant(function, Representation::Tagged()); | 6989 return new(zone()) HConstant(function); |
7005 } | 6990 } |
7006 | 6991 |
7007 // Handle a load from a known field somewhere in the prototype chain. | 6992 // Handle a load from a known field somewhere in the prototype chain. |
7008 LookupInPrototypes(map, name, &lookup); | 6993 LookupInPrototypes(map, name, &lookup); |
7009 if (lookup.IsField()) { | 6994 if (lookup.IsField()) { |
7010 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6995 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
7011 Handle<JSObject> holder(lookup.holder()); | 6996 Handle<JSObject> holder(lookup.holder()); |
7012 Handle<Map> holder_map(holder->map()); | 6997 Handle<Map> holder_map(holder->map()); |
7013 AddCheckMap(object, map); | 6998 AddCheckMap(object, map); |
7014 AddInstruction(new(zone()) HCheckPrototypeMaps( | 6999 AddInstruction(new(zone()) HCheckPrototypeMaps( |
7015 prototype, holder, zone(), top_info())); | 7000 prototype, holder, zone(), top_info())); |
7016 HValue* holder_value = AddInstruction(new(zone()) | 7001 HValue* holder_value = AddInstruction(new(zone()) HConstant(holder)); |
7017 HConstant(holder, Representation::Tagged())); | |
7018 return BuildLoadNamedField(holder_value, | 7002 return BuildLoadNamedField(holder_value, |
7019 HObjectAccess::ForField(holder_map, &lookup, name), | 7003 HObjectAccess::ForField(holder_map, &lookup, name), |
7020 ComputeLoadStoreRepresentation(map, &lookup)); | 7004 ComputeLoadStoreRepresentation(map, &lookup)); |
7021 } | 7005 } |
7022 | 7006 |
7023 // Handle a load of a constant function somewhere in the prototype chain. | 7007 // Handle a load of a constant function somewhere in the prototype chain. |
7024 if (lookup.IsConstantFunction()) { | 7008 if (lookup.IsConstantFunction()) { |
7025 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 7009 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
7026 Handle<JSObject> holder(lookup.holder()); | 7010 Handle<JSObject> holder(lookup.holder()); |
7027 Handle<Map> holder_map(holder->map()); | 7011 Handle<Map> holder_map(holder->map()); |
7028 AddCheckMap(object, map); | 7012 AddCheckMap(object, map); |
7029 AddInstruction(new(zone()) HCheckPrototypeMaps( | 7013 AddInstruction(new(zone()) HCheckPrototypeMaps( |
7030 prototype, holder, zone(), top_info())); | 7014 prototype, holder, zone(), top_info())); |
7031 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map)); | 7015 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map)); |
7032 return new(zone()) HConstant(function, Representation::Tagged()); | 7016 return new(zone()) HConstant(function); |
7033 } | 7017 } |
7034 | 7018 |
7035 // No luck, do a generic load. | 7019 // No luck, do a generic load. |
7036 return BuildLoadNamedGeneric(object, name, expr); | 7020 return BuildLoadNamedGeneric(object, name, expr); |
7037 } | 7021 } |
7038 | 7022 |
7039 | 7023 |
7040 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, | 7024 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, |
7041 HValue* key) { | 7025 HValue* key) { |
7042 HValue* context = environment()->LookupContext(); | 7026 HValue* context = environment()->LookupContext(); |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8003 undefined, | 7987 undefined, |
8004 function_state()->inlining_kind(), | 7988 function_state()->inlining_kind(), |
8005 undefined_receiver); | 7989 undefined_receiver); |
8006 #ifdef V8_TARGET_ARCH_IA32 | 7990 #ifdef V8_TARGET_ARCH_IA32 |
8007 // IA32 only, overwrite the caller's context in the deoptimization | 7991 // IA32 only, overwrite the caller's context in the deoptimization |
8008 // environment with the correct one. | 7992 // environment with the correct one. |
8009 // | 7993 // |
8010 // TODO(kmillikin): implement the same inlining on other platforms so we | 7994 // TODO(kmillikin): implement the same inlining on other platforms so we |
8011 // can remove the unsightly ifdefs in this function. | 7995 // can remove the unsightly ifdefs in this function. |
8012 HConstant* context = | 7996 HConstant* context = |
8013 new(zone()) HConstant(Handle<Context>(target->context()), | 7997 new(zone()) HConstant(Handle<Context>(target->context())); |
8014 Representation::Tagged()); | |
8015 AddInstruction(context); | 7998 AddInstruction(context); |
8016 inner_env->BindContext(context); | 7999 inner_env->BindContext(context); |
8017 #endif | 8000 #endif |
8018 | 8001 |
8019 AddSimulate(return_id); | 8002 AddSimulate(return_id); |
8020 current_block()->UpdateEnvironment(inner_env); | 8003 current_block()->UpdateEnvironment(inner_env); |
8021 HArgumentsObject* arguments_object = NULL; | 8004 HArgumentsObject* arguments_object = NULL; |
8022 | 8005 |
8023 // If the function uses arguments object create and bind one, also copy | 8006 // If the function uses arguments object create and bind one, also copy |
8024 // current arguments values to use them for materialization. | 8007 // current arguments values to use them for materialization. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8344 Pop(); // Pop receiver. | 8327 Pop(); // Pop receiver. |
8345 HValue* context = environment()->LookupContext(); | 8328 HValue* context = environment()->LookupContext(); |
8346 HInstruction* result = NULL; | 8329 HInstruction* result = NULL; |
8347 // Use sqrt() if exponent is 0.5 or -0.5. | 8330 // Use sqrt() if exponent is 0.5 or -0.5. |
8348 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { | 8331 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { |
8349 double exponent = HConstant::cast(right)->DoubleValue(); | 8332 double exponent = HConstant::cast(right)->DoubleValue(); |
8350 if (exponent == 0.5) { | 8333 if (exponent == 0.5) { |
8351 result = | 8334 result = |
8352 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); | 8335 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); |
8353 } else if (exponent == -0.5) { | 8336 } else if (exponent == -0.5) { |
8354 HConstant* double_one = new(zone()) HConstant( | 8337 HValue* one = graph()->GetConstant1(); |
8355 1, Representation::Double()); | |
8356 AddInstruction(double_one); | |
8357 HInstruction* sqrt = | 8338 HInstruction* sqrt = |
8358 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); | 8339 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf); |
8359 AddInstruction(sqrt); | 8340 AddInstruction(sqrt); |
8360 // MathPowHalf doesn't have side effects so there's no need for | 8341 // MathPowHalf doesn't have side effects so there's no need for |
8361 // an environment simulation here. | 8342 // an environment simulation here. |
8362 ASSERT(!sqrt->HasObservableSideEffects()); | 8343 ASSERT(!sqrt->HasObservableSideEffects()); |
8363 result = HDiv::New(zone(), context, double_one, sqrt); | 8344 result = HDiv::New(zone(), context, one, sqrt); |
8364 } else if (exponent == 2.0) { | 8345 } else if (exponent == 2.0) { |
8365 result = HMul::New(zone(), context, left, left); | 8346 result = HMul::New(zone(), context, left, left); |
8366 } | 8347 } |
8367 } else if (right->EqualsInteger32Constant(2)) { | 8348 } else if (right->EqualsInteger32Constant(2)) { |
8368 result = HMul::New(zone(), context, left, left); | 8349 result = HMul::New(zone(), context, left, left); |
8369 } | 8350 } |
8370 | 8351 |
8371 if (result == NULL) { | 8352 if (result == NULL) { |
8372 result = HPower::New(zone(), left, right); | 8353 result = HPower::New(zone(), left, right); |
8373 } | 8354 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8819 } | 8800 } |
8820 | 8801 |
8821 // Calculate instance size from initial map of constructor. | 8802 // Calculate instance size from initial map of constructor. |
8822 ASSERT(constructor->has_initial_map()); | 8803 ASSERT(constructor->has_initial_map()); |
8823 Handle<Map> initial_map(constructor->initial_map()); | 8804 Handle<Map> initial_map(constructor->initial_map()); |
8824 int instance_size = initial_map->instance_size(); | 8805 int instance_size = initial_map->instance_size(); |
8825 ASSERT(initial_map->InitialPropertiesLength() == 0); | 8806 ASSERT(initial_map->InitialPropertiesLength() == 0); |
8826 | 8807 |
8827 // Allocate an instance of the implicit receiver object. | 8808 // Allocate an instance of the implicit receiver object. |
8828 HValue* size_in_bytes = | 8809 HValue* size_in_bytes = |
8829 AddInstruction(new(zone()) HConstant(instance_size, | 8810 AddInstruction(new(zone()) HConstant(instance_size)); |
8830 Representation::Integer32())); | |
8831 | 8811 |
8832 HAllocate::Flags flags = HAllocate::DefaultFlags(); | 8812 HAllocate::Flags flags = HAllocate::DefaultFlags(); |
8833 if (FLAG_pretenuring_call_new && | 8813 if (FLAG_pretenuring_call_new && |
8834 isolate()->heap()->ShouldGloballyPretenure()) { | 8814 isolate()->heap()->ShouldGloballyPretenure()) { |
8835 flags = static_cast<HAllocate::Flags>( | 8815 flags = static_cast<HAllocate::Flags>( |
8836 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 8816 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
8837 } | 8817 } |
8838 | 8818 |
8839 HInstruction* receiver = | 8819 HInstruction* receiver = |
8840 AddInstruction(new(zone()) HAllocate(context, | 8820 AddInstruction(new(zone()) HAllocate(context, |
8841 size_in_bytes, | 8821 size_in_bytes, |
8842 HType::JSObject(), | 8822 HType::JSObject(), |
8843 flags)); | 8823 flags)); |
8844 HAllocate::cast(receiver)->set_known_initial_map(initial_map); | 8824 HAllocate::cast(receiver)->set_known_initial_map(initial_map); |
8845 | 8825 |
8846 // Load the initial map from the constructor. | 8826 // Load the initial map from the constructor. |
8847 HValue* constructor_value = | 8827 HValue* constructor_value = |
8848 AddInstruction(new(zone()) HConstant(constructor, | 8828 AddInstruction(new(zone()) HConstant(constructor)); |
8849 Representation::Tagged())); | |
8850 HValue* initial_map_value = | 8829 HValue* initial_map_value = |
8851 AddLoad(constructor_value, HObjectAccess::ForJSObjectOffset( | 8830 AddLoad(constructor_value, HObjectAccess::ForJSObjectOffset( |
8852 JSFunction::kPrototypeOrInitialMapOffset)); | 8831 JSFunction::kPrototypeOrInitialMapOffset)); |
8853 | 8832 |
8854 // Initialize map and fields of the newly allocated object. | 8833 // Initialize map and fields of the newly allocated object. |
8855 { NoObservableSideEffectsScope no_effects(this); | 8834 { NoObservableSideEffectsScope no_effects(this); |
8856 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | 8835 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); |
8857 AddStore(receiver, | 8836 AddStore(receiver, |
8858 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), | 8837 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), |
8859 initial_map_value); | 8838 initial_map_value); |
8860 HValue* empty_fixed_array = | 8839 HValue* empty_fixed_array = |
8861 AddInstruction(new(zone()) HConstant(factory->empty_fixed_array(), | 8840 AddInstruction(new(zone()) HConstant(factory->empty_fixed_array())); |
8862 Representation::Tagged())); | |
8863 AddStore(receiver, | 8841 AddStore(receiver, |
8864 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), | 8842 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), |
8865 empty_fixed_array); | 8843 empty_fixed_array); |
8866 AddStore(receiver, | 8844 AddStore(receiver, |
8867 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), | 8845 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), |
8868 empty_fixed_array); | 8846 empty_fixed_array); |
8869 if (initial_map->inobject_properties() != 0) { | 8847 if (initial_map->inobject_properties() != 0) { |
8870 HConstant* undefined = graph()->GetConstantUndefined(); | 8848 HConstant* undefined = graph()->GetConstantUndefined(); |
8871 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 8849 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
8872 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 8850 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9354 HValue* context, | 9332 HValue* context, |
9355 HValue* string, | 9333 HValue* string, |
9356 HValue* index) { | 9334 HValue* index) { |
9357 if (string->IsConstant() && index->IsConstant()) { | 9335 if (string->IsConstant() && index->IsConstant()) { |
9358 HConstant* c_string = HConstant::cast(string); | 9336 HConstant* c_string = HConstant::cast(string); |
9359 HConstant* c_index = HConstant::cast(index); | 9337 HConstant* c_index = HConstant::cast(index); |
9360 if (c_string->HasStringValue() && c_index->HasNumberValue()) { | 9338 if (c_string->HasStringValue() && c_index->HasNumberValue()) { |
9361 int32_t i = c_index->NumberValueAsInteger32(); | 9339 int32_t i = c_index->NumberValueAsInteger32(); |
9362 Handle<String> s = c_string->StringValue(); | 9340 Handle<String> s = c_string->StringValue(); |
9363 if (i < 0 || i >= s->length()) { | 9341 if (i < 0 || i >= s->length()) { |
9364 return new(zone()) HConstant(OS::nan_value(), Representation::Double()); | 9342 return new(zone()) HConstant(OS::nan_value()); |
9365 } | 9343 } |
9366 return new(zone()) HConstant(s->Get(i)); | 9344 return new(zone()) HConstant(s->Get(i)); |
9367 } | 9345 } |
9368 } | 9346 } |
9369 BuildCheckNonSmi(string); | 9347 BuildCheckNonSmi(string); |
9370 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); | 9348 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
9371 HInstruction* length = HStringLength::New(zone(), string); | 9349 HInstruction* length = HStringLength::New(zone(), string); |
9372 AddInstruction(length); | 9350 AddInstruction(length); |
9373 HInstruction* checked_index = AddBoundsCheck(index, length); | 9351 HInstruction* checked_index = AddBoundsCheck(index, length); |
9374 return new(zone()) HStringCharCodeAt(context, string, checked_index); | 9352 return new(zone()) HStringCharCodeAt(context, string, checked_index); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9947 BuildCompareNil(value, type, expr->position(), &continuation); | 9925 BuildCompareNil(value, type, expr->position(), &continuation); |
9948 return ast_context()->ReturnContinuation(&continuation, expr->id()); | 9926 return ast_context()->ReturnContinuation(&continuation, expr->id()); |
9949 } | 9927 } |
9950 | 9928 |
9951 | 9929 |
9952 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { | 9930 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { |
9953 // If we share optimized code between different closures, the | 9931 // If we share optimized code between different closures, the |
9954 // this-function is not a constant, except inside an inlined body. | 9932 // this-function is not a constant, except inside an inlined body. |
9955 if (function_state()->outer() != NULL) { | 9933 if (function_state()->outer() != NULL) { |
9956 return new(zone()) HConstant( | 9934 return new(zone()) HConstant( |
9957 function_state()->compilation_info()->closure(), | 9935 function_state()->compilation_info()->closure()); |
9958 Representation::Tagged()); | |
9959 } else { | 9936 } else { |
9960 return new(zone()) HThisFunction; | 9937 return new(zone()) HThisFunction; |
9961 } | 9938 } |
9962 } | 9939 } |
9963 | 9940 |
9964 | 9941 |
9965 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( | 9942 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
9966 HValue* context, | 9943 HValue* context, |
9967 Handle<JSObject> boilerplate_object, | 9944 Handle<JSObject> boilerplate_object, |
9968 Handle<JSObject> original_boilerplate_object, | 9945 Handle<JSObject> original_boilerplate_object, |
9969 int data_size, | 9946 int data_size, |
9970 int pointer_size, | 9947 int pointer_size, |
9971 AllocationSiteMode mode) { | 9948 AllocationSiteMode mode) { |
9972 Zone* zone = this->zone(); | 9949 Zone* zone = this->zone(); |
9973 int total_size = data_size + pointer_size; | 9950 int total_size = data_size + pointer_size; |
9974 | 9951 |
9975 NoObservableSideEffectsScope no_effects(this); | 9952 NoObservableSideEffectsScope no_effects(this); |
9976 | 9953 |
9977 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 9954 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
9978 // TODO(hpayer): add support for old data space | 9955 // TODO(hpayer): add support for old data space |
9979 if (isolate()->heap()->ShouldGloballyPretenure() && | 9956 if (isolate()->heap()->ShouldGloballyPretenure() && |
9980 data_size == 0) { | 9957 data_size == 0) { |
9981 flags = static_cast<HAllocate::Flags>( | 9958 flags = static_cast<HAllocate::Flags>( |
9982 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 9959 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
9983 } | 9960 } |
9984 | 9961 |
9985 HValue* size_in_bytes = | 9962 HValue* size_in_bytes = AddInstruction(new(zone) HConstant(total_size)); |
9986 AddInstruction(new(zone) HConstant(total_size, | |
9987 Representation::Integer32())); | |
9988 HInstruction* result = | 9963 HInstruction* result = |
9989 AddInstruction(new(zone) HAllocate(context, | 9964 AddInstruction(new(zone) HAllocate(context, |
9990 size_in_bytes, | 9965 size_in_bytes, |
9991 HType::JSObject(), | 9966 HType::JSObject(), |
9992 flags)); | 9967 flags)); |
9993 int offset = 0; | 9968 int offset = 0; |
9994 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, | 9969 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, |
9995 &offset, mode); | 9970 &offset, mode); |
9996 return result; | 9971 return result; |
9997 } | 9972 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10034 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); | 10009 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); |
10035 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, | 10010 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, |
10036 object_properties, target, offset); | 10011 object_properties, target, offset); |
10037 | 10012 |
10038 // Create allocation site info. | 10013 // Create allocation site info. |
10039 if (mode == TRACK_ALLOCATION_SITE && | 10014 if (mode == TRACK_ALLOCATION_SITE && |
10040 boilerplate_object->map()->CanTrackAllocationSite()) { | 10015 boilerplate_object->map()->CanTrackAllocationSite()) { |
10041 elements_offset += AllocationSiteInfo::kSize; | 10016 elements_offset += AllocationSiteInfo::kSize; |
10042 *offset += AllocationSiteInfo::kSize; | 10017 *offset += AllocationSiteInfo::kSize; |
10043 HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( | 10018 HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( |
10044 original_boilerplate_object, Representation::Tagged())); | 10019 original_boilerplate_object)); |
10045 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); | 10020 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); |
10046 } | 10021 } |
10047 } | 10022 } |
10048 | 10023 |
10049 | 10024 |
10050 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( | 10025 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( |
10051 Handle<JSObject> boilerplate_object, | 10026 Handle<JSObject> boilerplate_object, |
10052 HInstruction* target, | 10027 HInstruction* target, |
10053 int object_offset, | 10028 int object_offset, |
10054 int elements_offset, | 10029 int elements_offset, |
10055 int elements_size) { | 10030 int elements_size) { |
10056 ASSERT(boilerplate_object->properties()->length() == 0); | 10031 ASSERT(boilerplate_object->properties()->length() == 0); |
10057 Zone* zone = this->zone(); | 10032 Zone* zone = this->zone(); |
10058 HValue* result = NULL; | 10033 HValue* result = NULL; |
10059 | 10034 |
10060 HValue* object_header = | 10035 HValue* object_header = |
10061 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); | 10036 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); |
10062 Handle<Map> boilerplate_object_map(boilerplate_object->map()); | 10037 Handle<Map> boilerplate_object_map(boilerplate_object->map()); |
10063 AddStoreMapConstant(object_header, boilerplate_object_map); | 10038 AddStoreMapConstant(object_header, boilerplate_object_map); |
10064 | 10039 |
10065 HInstruction* elements; | 10040 HInstruction* elements; |
10066 if (elements_size == 0) { | 10041 if (elements_size == 0) { |
10067 Handle<Object> elements_field = | 10042 Handle<Object> elements_field = |
10068 Handle<Object>(boilerplate_object->elements(), isolate()); | 10043 Handle<Object>(boilerplate_object->elements(), isolate()); |
10069 elements = AddInstruction(new(zone) HConstant( | 10044 elements = AddInstruction(new(zone) HConstant(elements_field)); |
10070 elements_field, Representation::Tagged())); | |
10071 } else { | 10045 } else { |
10072 elements = AddInstruction(new(zone) HInnerAllocatedObject( | 10046 elements = AddInstruction(new(zone) HInnerAllocatedObject( |
10073 target, elements_offset)); | 10047 target, elements_offset)); |
10074 result = elements; | 10048 result = elements; |
10075 } | 10049 } |
10076 AddStore(object_header, HObjectAccess::ForElementsPointer(), elements); | 10050 AddStore(object_header, HObjectAccess::ForElementsPointer(), elements); |
10077 | 10051 |
10078 Handle<Object> properties_field = | 10052 Handle<Object> properties_field = |
10079 Handle<Object>(boilerplate_object->properties(), isolate()); | 10053 Handle<Object>(boilerplate_object->properties(), isolate()); |
10080 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); | 10054 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); |
10081 HInstruction* properties = AddInstruction(new(zone) HConstant( | 10055 HInstruction* properties = AddInstruction(new(zone) HConstant( |
10082 properties_field, Representation::None())); | 10056 properties_field)); |
10083 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 10057 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
10084 AddStore(object_header, access, properties); | 10058 AddStore(object_header, access, properties); |
10085 | 10059 |
10086 if (boilerplate_object->IsJSArray()) { | 10060 if (boilerplate_object->IsJSArray()) { |
10087 Handle<JSArray> boilerplate_array = | 10061 Handle<JSArray> boilerplate_array = |
10088 Handle<JSArray>::cast(boilerplate_object); | 10062 Handle<JSArray>::cast(boilerplate_object); |
10089 Handle<Object> length_field = | 10063 Handle<Object> length_field = |
10090 Handle<Object>(boilerplate_array->length(), isolate()); | 10064 Handle<Object>(boilerplate_array->length(), isolate()); |
10091 HInstruction* length = AddInstruction(new(zone) HConstant( | 10065 HInstruction* length = AddInstruction(new(zone) HConstant(length_field)); |
10092 length_field, Representation::None())); | |
10093 | 10066 |
10094 ASSERT(boilerplate_array->length()->IsSmi()); | 10067 ASSERT(boilerplate_array->length()->IsSmi()); |
10095 Representation representation = | 10068 Representation representation = |
10096 IsFastElementsKind(boilerplate_array->GetElementsKind()) | 10069 IsFastElementsKind(boilerplate_array->GetElementsKind()) |
10097 ? Representation::Smi() : Representation::Tagged(); | 10070 ? Representation::Smi() : Representation::Tagged(); |
10098 AddStore(object_header, HObjectAccess::ForArrayLength(), | 10071 AddStore(object_header, HObjectAccess::ForArrayLength(), |
10099 length, representation); | 10072 length, representation); |
10100 } | 10073 } |
10101 | 10074 |
10102 return result; | 10075 return result; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10138 isolate())); | 10111 isolate())); |
10139 HInstruction* value_instruction = | 10112 HInstruction* value_instruction = |
10140 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); | 10113 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
10141 | 10114 |
10142 AddStore(object_properties, access, value_instruction); | 10115 AddStore(object_properties, access, value_instruction); |
10143 | 10116 |
10144 BuildEmitDeepCopy(value_object, original_value_object, target, | 10117 BuildEmitDeepCopy(value_object, original_value_object, target, |
10145 offset, DONT_TRACK_ALLOCATION_SITE); | 10118 offset, DONT_TRACK_ALLOCATION_SITE); |
10146 } else { | 10119 } else { |
10147 Representation representation = details.representation(); | 10120 Representation representation = details.representation(); |
10148 HInstruction* value_instruction = AddInstruction(new(zone) HConstant( | 10121 HInstruction* value_instruction = |
10149 value, Representation::Tagged())); | 10122 AddInstruction(new(zone) HConstant(value)); |
10150 | 10123 |
10151 if (representation.IsDouble()) { | 10124 if (representation.IsDouble()) { |
10152 // Allocate a HeapNumber box and store the value into it. | 10125 // Allocate a HeapNumber box and store the value into it. |
10153 HInstruction* double_box = | 10126 HInstruction* double_box = |
10154 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); | 10127 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
10155 AddStoreMapConstant(double_box, | 10128 AddStoreMapConstant(double_box, |
10156 isolate()->factory()->heap_number_map()); | 10129 isolate()->factory()->heap_number_map()); |
10157 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), | 10130 AddStore(double_box, HObjectAccess::ForHeapNumberValue(), |
10158 value_instruction, Representation::Double()); | 10131 value_instruction, Representation::Double()); |
10159 value_instruction = double_box; | 10132 value_instruction = double_box; |
10160 *offset += HeapNumber::kSize; | 10133 *offset += HeapNumber::kSize; |
10161 } | 10134 } |
10162 | 10135 |
10163 AddStore(object_properties, access, value_instruction); | 10136 AddStore(object_properties, access, value_instruction); |
10164 } | 10137 } |
10165 } | 10138 } |
10166 | 10139 |
10167 int inobject_properties = boilerplate_object->map()->inobject_properties(); | 10140 int inobject_properties = boilerplate_object->map()->inobject_properties(); |
10168 HInstruction* value_instruction = AddInstruction(new(zone) | 10141 HInstruction* value_instruction = AddInstruction(new(zone) |
10169 HConstant(isolate()->factory()->one_pointer_filler_map(), | 10142 HConstant(isolate()->factory()->one_pointer_filler_map())); |
10170 Representation::Tagged())); | |
10171 for (int i = copied_fields; i < inobject_properties; i++) { | 10143 for (int i = copied_fields; i < inobject_properties; i++) { |
10172 ASSERT(boilerplate_object->IsJSObject()); | 10144 ASSERT(boilerplate_object->IsJSObject()); |
10173 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); | 10145 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); |
10174 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); | 10146 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); |
10175 AddStore(object_properties, access, value_instruction); | 10147 AddStore(object_properties, access, value_instruction); |
10176 } | 10148 } |
10177 } | 10149 } |
10178 | 10150 |
10179 | 10151 |
10180 void HOptimizedGraphBuilder::BuildEmitElements( | 10152 void HOptimizedGraphBuilder::BuildEmitElements( |
(...skipping 21 matching lines...) Expand all Loading... |
10202 UNREACHABLE(); | 10174 UNREACHABLE(); |
10203 } | 10175 } |
10204 } | 10176 } |
10205 | 10177 |
10206 | 10178 |
10207 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( | 10179 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( |
10208 Handle<FixedArrayBase> elements, | 10180 Handle<FixedArrayBase> elements, |
10209 ElementsKind kind, | 10181 ElementsKind kind, |
10210 HValue* object_elements) { | 10182 HValue* object_elements) { |
10211 Zone* zone = this->zone(); | 10183 Zone* zone = this->zone(); |
10212 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant( | 10184 HInstruction* boilerplate_elements = |
10213 elements, Representation::Tagged())); | 10185 AddInstruction(new(zone) HConstant(elements)); |
10214 int elements_length = elements->length(); | 10186 int elements_length = elements->length(); |
10215 for (int i = 0; i < elements_length; i++) { | 10187 for (int i = 0; i < elements_length; i++) { |
10216 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); | 10188 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); |
10217 HInstruction* value_instruction = | 10189 HInstruction* value_instruction = |
10218 AddInstruction(new(zone) HLoadKeyed( | 10190 AddInstruction(new(zone) HLoadKeyed( |
10219 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE)); | 10191 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE)); |
10220 HInstruction* store = AddInstruction(new(zone) HStoreKeyed( | 10192 HInstruction* store = AddInstruction(new(zone) HStoreKeyed( |
10221 object_elements, key_constant, value_instruction, kind)); | 10193 object_elements, key_constant, value_instruction, kind)); |
10222 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 10194 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
10223 } | 10195 } |
10224 } | 10196 } |
10225 | 10197 |
10226 | 10198 |
10227 void HOptimizedGraphBuilder::BuildEmitFixedArray( | 10199 void HOptimizedGraphBuilder::BuildEmitFixedArray( |
10228 Handle<FixedArrayBase> elements, | 10200 Handle<FixedArrayBase> elements, |
10229 Handle<FixedArrayBase> original_elements, | 10201 Handle<FixedArrayBase> original_elements, |
10230 ElementsKind kind, | 10202 ElementsKind kind, |
10231 HValue* object_elements, | 10203 HValue* object_elements, |
10232 HInstruction* target, | 10204 HInstruction* target, |
10233 int* offset) { | 10205 int* offset) { |
10234 Zone* zone = this->zone(); | 10206 Zone* zone = this->zone(); |
10235 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant( | 10207 HInstruction* boilerplate_elements = |
10236 elements, Representation::Tagged())); | 10208 AddInstruction(new(zone) HConstant(elements)); |
10237 int elements_length = elements->length(); | 10209 int elements_length = elements->length(); |
10238 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); | 10210 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); |
10239 Handle<FixedArray> original_fast_elements = | 10211 Handle<FixedArray> original_fast_elements = |
10240 Handle<FixedArray>::cast(original_elements); | 10212 Handle<FixedArray>::cast(original_elements); |
10241 for (int i = 0; i < elements_length; i++) { | 10213 for (int i = 0; i < elements_length; i++) { |
10242 Handle<Object> value(fast_elements->get(i), isolate()); | 10214 Handle<Object> value(fast_elements->get(i), isolate()); |
10243 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); | 10215 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); |
10244 if (value->IsJSObject()) { | 10216 if (value->IsJSObject()) { |
10245 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 10217 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
10246 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 10218 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11611 } | 11583 } |
11612 } | 11584 } |
11613 | 11585 |
11614 #ifdef DEBUG | 11586 #ifdef DEBUG |
11615 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11587 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11616 if (allocator_ != NULL) allocator_->Verify(); | 11588 if (allocator_ != NULL) allocator_->Verify(); |
11617 #endif | 11589 #endif |
11618 } | 11590 } |
11619 | 11591 |
11620 } } // namespace v8::internal | 11592 } } // namespace v8::internal |
OLD | NEW |