| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 130 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 131 __ jmp(offset); | 131 __ jmp(offset); |
| 132 | 132 |
| 133 // Pop at miss. | 133 // Pop at miss. |
| 134 __ bind(&miss); | 134 __ bind(&miss); |
| 135 __ pop(offset); | 135 __ pop(offset); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 // Helper function used to check that the dictionary doesn't contain | 140 void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
| 141 // the property. This function may return false negatives, so miss_label | 141 Label* miss_label, |
| 142 // must always call a backup property check that is complete. | 142 Register receiver, |
| 143 // This function is safe to call if the receiver has fast properties. | 143 Handle<Name> name, |
| 144 // Name must be unique and receiver must be a heap object. | 144 Register scratch0, |
| 145 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 145 Register scratch1) { |
| 146 Label* miss_label, | |
| 147 Register receiver, | |
| 148 Handle<Name> name, | |
| 149 Register r0, | |
| 150 Register r1) { | |
| 151 ASSERT(name->IsUniqueName()); | 146 ASSERT(name->IsUniqueName()); |
| 147 ASSERT(!receiver.is(scratch0)); |
| 152 Counters* counters = masm->isolate()->counters(); | 148 Counters* counters = masm->isolate()->counters(); |
| 153 __ IncrementCounter(counters->negative_lookups(), 1); | 149 __ IncrementCounter(counters->negative_lookups(), 1); |
| 154 __ IncrementCounter(counters->negative_lookups_miss(), 1); | 150 __ IncrementCounter(counters->negative_lookups_miss(), 1); |
| 155 | 151 |
| 156 __ mov(r0, FieldOperand(receiver, HeapObject::kMapOffset)); | 152 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 157 | 153 |
| 158 const int kInterceptorOrAccessCheckNeededMask = | 154 const int kInterceptorOrAccessCheckNeededMask = |
| 159 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 155 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
| 160 | 156 |
| 161 // Bail out if the receiver has a named interceptor or requires access checks. | 157 // Bail out if the receiver has a named interceptor or requires access checks. |
| 162 __ test_b(FieldOperand(r0, Map::kBitFieldOffset), | 158 __ test_b(FieldOperand(scratch0, Map::kBitFieldOffset), |
| 163 kInterceptorOrAccessCheckNeededMask); | 159 kInterceptorOrAccessCheckNeededMask); |
| 164 __ j(not_zero, miss_label); | 160 __ j(not_zero, miss_label); |
| 165 | 161 |
| 166 // Check that receiver is a JSObject. | 162 // Check that receiver is a JSObject. |
| 167 __ CmpInstanceType(r0, FIRST_SPEC_OBJECT_TYPE); | 163 __ CmpInstanceType(scratch0, FIRST_SPEC_OBJECT_TYPE); |
| 168 __ j(below, miss_label); | 164 __ j(below, miss_label); |
| 169 | 165 |
| 170 // Load properties array. | 166 // Load properties array. |
| 171 Register properties = r0; | 167 Register properties = scratch0; |
| 172 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); | 168 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
| 173 | 169 |
| 174 // Check that the properties array is a dictionary. | 170 // Check that the properties array is a dictionary. |
| 175 __ cmp(FieldOperand(properties, HeapObject::kMapOffset), | 171 __ cmp(FieldOperand(properties, HeapObject::kMapOffset), |
| 176 Immediate(masm->isolate()->factory()->hash_table_map())); | 172 Immediate(masm->isolate()->factory()->hash_table_map())); |
| 177 __ j(not_equal, miss_label); | 173 __ j(not_equal, miss_label); |
| 178 | 174 |
| 179 Label done; | 175 Label done; |
| 180 NameDictionaryLookupStub::GenerateNegativeLookup(masm, | 176 NameDictionaryLookupStub::GenerateNegativeLookup(masm, |
| 181 miss_label, | 177 miss_label, |
| 182 &done, | 178 &done, |
| 183 properties, | 179 properties, |
| 184 name, | 180 name, |
| 185 r1); | 181 scratch1); |
| 186 __ bind(&done); | 182 __ bind(&done); |
| 187 __ DecrementCounter(counters->negative_lookups_miss(), 1); | 183 __ DecrementCounter(counters->negative_lookups_miss(), 1); |
| 188 } | 184 } |
| 189 | 185 |
| 190 | 186 |
| 191 void StubCache::GenerateProbe(MacroAssembler* masm, | 187 void StubCache::GenerateProbe(MacroAssembler* masm, |
| 192 Code::Flags flags, | 188 Code::Flags flags, |
| 193 Register receiver, | 189 Register receiver, |
| 194 Register name, | 190 Register name, |
| 195 Register scratch, | 191 Register scratch, |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 if (!label->is_unused()) { | 748 if (!label->is_unused()) { |
| 753 __ bind(label); | 749 __ bind(label); |
| 754 __ mov(this->name(), Immediate(name)); | 750 __ mov(this->name(), Immediate(name)); |
| 755 } | 751 } |
| 756 } | 752 } |
| 757 | 753 |
| 758 | 754 |
| 759 // Generate code to check that a global property cell is empty. Create | 755 // Generate code to check that a global property cell is empty. Create |
| 760 // the property cell at compilation time if no cell exists for the | 756 // the property cell at compilation time if no cell exists for the |
| 761 // property. | 757 // property. |
| 762 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 758 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 763 Handle<GlobalObject> global, | 759 Handle<JSGlobalObject> global, |
| 764 Handle<Name> name, | 760 Handle<Name> name, |
| 765 Register scratch, | 761 Register scratch, |
| 766 Label* miss) { | 762 Label* miss) { |
| 767 Handle<PropertyCell> cell = | 763 Handle<PropertyCell> cell = |
| 768 GlobalObject::EnsurePropertyCell(global, name); | 764 JSGlobalObject::EnsurePropertyCell(global, name); |
| 769 ASSERT(cell->value()->IsTheHole()); | 765 ASSERT(cell->value()->IsTheHole()); |
| 770 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value(); | 766 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value(); |
| 771 if (Serializer::enabled()) { | 767 if (Serializer::enabled()) { |
| 772 __ mov(scratch, Immediate(cell)); | 768 __ mov(scratch, Immediate(cell)); |
| 773 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), | 769 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), |
| 774 Immediate(the_hole)); | 770 Immediate(the_hole)); |
| 775 } else { | 771 } else { |
| 776 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); | 772 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); |
| 777 } | 773 } |
| 778 __ j(not_equal, miss); | 774 __ j(not_equal, miss); |
| 779 } | 775 } |
| 780 | 776 |
| 781 | 777 |
| 782 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( | 778 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( |
| 783 MacroAssembler* masm, | 779 MacroAssembler* masm, |
| 784 Handle<JSObject> holder, | 780 Handle<JSObject> holder, |
| 785 Register holder_reg, | 781 Register holder_reg, |
| 786 Handle<Name> name, | 782 Handle<Name> name, |
| 787 Label* miss) { | 783 Label* miss) { |
| 788 if (holder->IsJSGlobalObject()) { | 784 if (holder->IsJSGlobalObject()) { |
| 789 GenerateCheckPropertyCell( | 785 GenerateCheckPropertyCell( |
| 790 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 786 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
| 791 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 787 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 792 GenerateDictionaryNegativeLookup( | 788 GenerateDictionaryNegativeLookup( |
| 793 masm, miss, holder_reg, name, scratch1(), scratch2()); | 789 masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 794 } | 790 } |
| 795 } | 791 } |
| 796 | 792 |
| 797 | 793 |
| 798 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if | 794 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if |
| 799 // store is successful. | 795 // store is successful. |
| 800 void BaseStoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, | 796 void BaseStoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 smi_check); | 1078 smi_check); |
| 1083 } | 1079 } |
| 1084 } | 1080 } |
| 1085 | 1081 |
| 1086 // Return the value (register eax). | 1082 // Return the value (register eax). |
| 1087 ASSERT(value_reg.is(eax)); | 1083 ASSERT(value_reg.is(eax)); |
| 1088 __ ret(0); | 1084 __ ret(0); |
| 1089 } | 1085 } |
| 1090 | 1086 |
| 1091 | 1087 |
| 1092 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1088 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1093 // from object to (but not including) holder. | 1089 Handle<JSObject> object, |
| 1094 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1090 Handle<JSObject> holder, |
| 1095 Handle<JSObject> object, | 1091 Handle<Name> name, |
| 1096 Handle<JSObject> holder, | 1092 Register scratch, |
| 1097 Handle<Name> name, | 1093 Label* miss) { |
| 1098 Register scratch, | |
| 1099 Label* miss) { | |
| 1100 Handle<JSObject> current = object; | 1094 Handle<JSObject> current = object; |
| 1101 while (!current.is_identical_to(holder)) { | 1095 while (!current.is_identical_to(holder)) { |
| 1102 if (current->IsGlobalObject()) { | 1096 if (current->IsJSGlobalObject()) { |
| 1103 GenerateCheckPropertyCell(masm, | 1097 GenerateCheckPropertyCell(masm, |
| 1104 Handle<GlobalObject>::cast(current), | 1098 Handle<JSGlobalObject>::cast(current), |
| 1105 name, | 1099 name, |
| 1106 scratch, | 1100 scratch, |
| 1107 miss); | 1101 miss); |
| 1108 } | 1102 } |
| 1109 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1103 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1110 } | 1104 } |
| 1111 } | 1105 } |
| 1112 | 1106 |
| 1113 | 1107 |
| 1114 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1108 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 } | 1308 } |
| 1315 __ cmp(scratch3(), callback); | 1309 __ cmp(scratch3(), callback); |
| 1316 __ j(not_equal, &miss); | 1310 __ j(not_equal, &miss); |
| 1317 } | 1311 } |
| 1318 | 1312 |
| 1319 HandlerFrontendFooter(name, success, &miss); | 1313 HandlerFrontendFooter(name, success, &miss); |
| 1320 return reg; | 1314 return reg; |
| 1321 } | 1315 } |
| 1322 | 1316 |
| 1323 | 1317 |
| 1324 void BaseLoadStubCompiler::NonexistentHandlerFrontend( | |
| 1325 Handle<JSObject> object, | |
| 1326 Handle<JSObject> last, | |
| 1327 Handle<Name> name, | |
| 1328 Label* success, | |
| 1329 Handle<GlobalObject> global) { | |
| 1330 Label miss; | |
| 1331 | |
| 1332 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
| 1333 | |
| 1334 // If the last object in the prototype chain is a global object, | |
| 1335 // check that the global property cell is empty. | |
| 1336 if (!global.is_null()) { | |
| 1337 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
| 1338 } | |
| 1339 | |
| 1340 HandlerFrontendFooter(name, success, &miss); | |
| 1341 } | |
| 1342 | |
| 1343 | |
| 1344 void BaseLoadStubCompiler::GenerateLoadField(Register reg, | 1318 void BaseLoadStubCompiler::GenerateLoadField(Register reg, |
| 1345 Handle<JSObject> holder, | 1319 Handle<JSObject> holder, |
| 1346 PropertyIndex field, | 1320 PropertyIndex field, |
| 1347 Representation representation) { | 1321 Representation representation) { |
| 1348 if (!reg.is(receiver())) __ mov(receiver(), reg); | 1322 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1349 if (kind() == Code::LOAD_IC) { | 1323 if (kind() == Code::LOAD_IC) { |
| 1350 LoadFieldStub stub(field.is_inobject(holder), | 1324 LoadFieldStub stub(field.is_inobject(holder), |
| 1351 field.translate(holder), | 1325 field.translate(holder), |
| 1352 representation); | 1326 representation); |
| 1353 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1327 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 // Return the generated code. | 2999 // Return the generated code. |
| 3026 return GetICCode( | 3000 return GetICCode( |
| 3027 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | 3001 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
| 3028 } | 3002 } |
| 3029 | 3003 |
| 3030 | 3004 |
| 3031 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 3005 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
| 3032 Handle<JSObject> object, | 3006 Handle<JSObject> object, |
| 3033 Handle<JSObject> last, | 3007 Handle<JSObject> last, |
| 3034 Handle<Name> name, | 3008 Handle<Name> name, |
| 3035 Handle<GlobalObject> global) { | 3009 Handle<JSGlobalObject> global) { |
| 3036 Label success; | 3010 Label success; |
| 3037 | 3011 |
| 3038 NonexistentHandlerFrontend(object, last, name, &success, global); | 3012 NonexistentHandlerFrontend(object, last, name, &success, global); |
| 3039 | 3013 |
| 3040 __ bind(&success); | 3014 __ bind(&success); |
| 3041 // Return undefined if maps of the full prototype chain are still the | 3015 // Return undefined if maps of the full prototype chain are still the |
| 3042 // same and no global property with this name contains a value. | 3016 // same and no global property with this name contains a value. |
| 3043 __ mov(eax, isolate()->factory()->undefined_value()); | 3017 __ mov(eax, isolate()->factory()->undefined_value()); |
| 3044 __ ret(0); | 3018 __ ret(0); |
| 3045 | 3019 |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3768 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3742 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
| 3769 } | 3743 } |
| 3770 } | 3744 } |
| 3771 | 3745 |
| 3772 | 3746 |
| 3773 #undef __ | 3747 #undef __ |
| 3774 | 3748 |
| 3775 } } // namespace v8::internal | 3749 } } // namespace v8::internal |
| 3776 | 3750 |
| 3777 #endif // V8_TARGET_ARCH_IA32 | 3751 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |