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