| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 __ pop(name_); | 642 __ pop(name_); |
| 643 __ LeaveInternalFrame(); | 643 __ LeaveInternalFrame(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 private: | 646 private: |
| 647 const ParameterCount& arguments_; | 647 const ParameterCount& arguments_; |
| 648 Register name_; | 648 Register name_; |
| 649 }; | 649 }; |
| 650 | 650 |
| 651 | 651 |
| 652 // Generate code to check that a global property cell is empty. Create |
| 653 // the property cell at compilation time if no cell exists for the |
| 654 // property. |
| 655 static Object* GenerateCheckPropertyCell(MacroAssembler* masm, |
| 656 GlobalObject* global, |
| 657 String* name, |
| 658 Register scratch, |
| 659 Label* miss) { |
| 660 Object* probe = global->EnsurePropertyCell(name); |
| 661 if (probe->IsFailure()) return probe; |
| 662 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe); |
| 663 ASSERT(cell->value()->IsTheHole()); |
| 664 __ Move(scratch, Handle<Object>(cell)); |
| 665 __ Cmp(FieldOperand(scratch, JSGlobalPropertyCell::kValueOffset), |
| 666 Factory::the_hole_value()); |
| 667 __ j(not_equal, miss); |
| 668 return cell; |
| 669 } |
| 670 |
| 671 |
| 652 #undef __ | 672 #undef __ |
| 653 | 673 |
| 654 #define __ ACCESS_MASM((masm())) | 674 #define __ ACCESS_MASM((masm())) |
| 655 | 675 |
| 656 | 676 |
| 657 Object* CallStubCompiler::CompileArrayPushCall(Object* object, | 677 Object* CallStubCompiler::CompileArrayPushCall(Object* object, |
| 658 JSObject* holder, | 678 JSObject* holder, |
| 659 JSFunction* function, | 679 JSFunction* function, |
| 660 String* name, | 680 String* name, |
| 661 CheckType check) { | 681 CheckType check) { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 __ movq(rax, Operand(rsp, kPointerSize)); | 1157 __ movq(rax, Operand(rsp, kPointerSize)); |
| 1138 GenerateLoadConstant(object, holder, rax, rbx, rdx, value, name, &miss); | 1158 GenerateLoadConstant(object, holder, rax, rbx, rdx, value, name, &miss); |
| 1139 __ bind(&miss); | 1159 __ bind(&miss); |
| 1140 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1160 GenerateLoadMiss(masm(), Code::LOAD_IC); |
| 1141 | 1161 |
| 1142 // Return the generated code. | 1162 // Return the generated code. |
| 1143 return GetCode(CONSTANT_FUNCTION, name); | 1163 return GetCode(CONSTANT_FUNCTION, name); |
| 1144 } | 1164 } |
| 1145 | 1165 |
| 1146 | 1166 |
| 1167 Object* LoadStubCompiler::CompileLoadNonexistent(String* name, |
| 1168 JSObject* object, |
| 1169 JSObject* last) { |
| 1170 // ----------- S t a t e ------------- |
| 1171 // -- rcx : name |
| 1172 // -- rsp[0] : return address |
| 1173 // -- rsp[8] : receiver |
| 1174 // ----------------------------------- |
| 1175 Label miss; |
| 1176 |
| 1177 // Load receiver. |
| 1178 __ movq(rax, Operand(rsp, kPointerSize)); |
| 1179 |
| 1180 // Check the maps of the full prototype chain. Also check that |
| 1181 // global property cells up to (but not including) the last object |
| 1182 // in the prototype chain are empty. |
| 1183 CheckPrototypes(object, rax, last, rbx, rdx, name, &miss); |
| 1184 |
| 1185 // If the last object in the prototype chain is a global object, |
| 1186 // check that the global property cell is empty. |
| 1187 if (last->IsGlobalObject()) { |
| 1188 Object* cell = GenerateCheckPropertyCell(masm(), |
| 1189 GlobalObject::cast(last), |
| 1190 name, |
| 1191 rdx, |
| 1192 &miss); |
| 1193 if (cell->IsFailure()) return cell; |
| 1194 } |
| 1195 |
| 1196 // Return undefined if maps of the full prototype chain is still the |
| 1197 // same and no global property with this name contains a value. |
| 1198 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 1199 __ ret(0); |
| 1200 |
| 1201 __ bind(&miss); |
| 1202 GenerateLoadMiss(masm(), Code::LOAD_IC); |
| 1203 |
| 1204 // Return the generated code. |
| 1205 return GetCode(NONEXISTENT, Heap::empty_string()); |
| 1206 } |
| 1207 |
| 1208 |
| 1147 Object* LoadStubCompiler::CompileLoadField(JSObject* object, | 1209 Object* LoadStubCompiler::CompileLoadField(JSObject* object, |
| 1148 JSObject* holder, | 1210 JSObject* holder, |
| 1149 int index, | 1211 int index, |
| 1150 String* name) { | 1212 String* name) { |
| 1151 // ----------- S t a t e ------------- | 1213 // ----------- S t a t e ------------- |
| 1152 // -- rcx : name | 1214 // -- rcx : name |
| 1153 // -- rsp[0] : return address | 1215 // -- rsp[0] : return address |
| 1154 // -- rsp[8] : receiver | 1216 // -- rsp[8] : receiver |
| 1155 // ----------------------------------- | 1217 // ----------------------------------- |
| 1156 Label miss; | 1218 Label miss; |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 int save_at_depth, | 1820 int save_at_depth, |
| 1759 Label* miss) { | 1821 Label* miss) { |
| 1760 // TODO(602): support object saving. | 1822 // TODO(602): support object saving. |
| 1761 ASSERT(save_at_depth == kInvalidProtoDepth); | 1823 ASSERT(save_at_depth == kInvalidProtoDepth); |
| 1762 | 1824 |
| 1763 // Check that the maps haven't changed. | 1825 // Check that the maps haven't changed. |
| 1764 Register result = | 1826 Register result = |
| 1765 __ CheckMaps(object, object_reg, holder, holder_reg, scratch, miss); | 1827 __ CheckMaps(object, object_reg, holder, holder_reg, scratch, miss); |
| 1766 | 1828 |
| 1767 // If we've skipped any global objects, it's not enough to verify | 1829 // If we've skipped any global objects, it's not enough to verify |
| 1768 // that their maps haven't changed. | 1830 // that their maps haven't changed. We also need to check that the |
| 1831 // property cell for the property is still empty. |
| 1769 while (object != holder) { | 1832 while (object != holder) { |
| 1770 if (object->IsGlobalObject()) { | 1833 if (object->IsGlobalObject()) { |
| 1771 GlobalObject* global = GlobalObject::cast(object); | 1834 Object* cell = GenerateCheckPropertyCell(masm(), |
| 1772 Object* probe = global->EnsurePropertyCell(name); | 1835 GlobalObject::cast(object), |
| 1773 if (probe->IsFailure()) { | 1836 name, |
| 1774 set_failure(Failure::cast(probe)); | 1837 scratch, |
| 1838 miss); |
| 1839 if (cell->IsFailure()) { |
| 1840 set_failure(Failure::cast(cell)); |
| 1775 return result; | 1841 return result; |
| 1776 } | 1842 } |
| 1777 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe); | |
| 1778 ASSERT(cell->value()->IsTheHole()); | |
| 1779 __ Move(scratch, Handle<Object>(cell)); | |
| 1780 __ Cmp(FieldOperand(scratch, JSGlobalPropertyCell::kValueOffset), | |
| 1781 Factory::the_hole_value()); | |
| 1782 __ j(not_equal, miss); | |
| 1783 } | 1843 } |
| 1784 object = JSObject::cast(object->GetPrototype()); | 1844 object = JSObject::cast(object->GetPrototype()); |
| 1785 } | 1845 } |
| 1786 | 1846 |
| 1787 // Return the register containing the holder. | 1847 // Return the register containing the holder. |
| 1788 return result; | 1848 return result; |
| 1789 } | 1849 } |
| 1790 | 1850 |
| 1791 | 1851 |
| 1792 void StubCompiler::GenerateLoadField(JSObject* object, | 1852 void StubCompiler::GenerateLoadField(JSObject* object, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 2019 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1960 | 2020 |
| 1961 // Return the generated code. | 2021 // Return the generated code. |
| 1962 return GetCode(); | 2022 return GetCode(); |
| 1963 } | 2023 } |
| 1964 | 2024 |
| 1965 | 2025 |
| 1966 #undef __ | 2026 #undef __ |
| 1967 | 2027 |
| 1968 } } // namespace v8::internal | 2028 } } // namespace v8::internal |
| OLD | NEW |