| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 if (!label->is_unused()) { | 781 if (!label->is_unused()) { |
| 786 __ bind(label); | 782 __ bind(label); |
| 787 __ mov(this->name(), Immediate(name)); | 783 __ mov(this->name(), Immediate(name)); |
| 788 } | 784 } |
| 789 } | 785 } |
| 790 | 786 |
| 791 | 787 |
| 792 // Generate code to check that a global property cell is empty. Create | 788 // Generate code to check that a global property cell is empty. Create |
| 793 // the property cell at compilation time if no cell exists for the | 789 // the property cell at compilation time if no cell exists for the |
| 794 // property. | 790 // property. |
| 795 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 791 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 796 Handle<GlobalObject> global, | 792 Handle<JSGlobalObject> global, |
| 797 Handle<Name> name, | 793 Handle<Name> name, |
| 798 Register scratch, | 794 Register scratch, |
| 799 Label* miss) { | 795 Label* miss) { |
| 800 Handle<PropertyCell> cell = | 796 Handle<PropertyCell> cell = |
| 801 GlobalObject::EnsurePropertyCell(global, name); | 797 JSGlobalObject::EnsurePropertyCell(global, name); |
| 802 ASSERT(cell->value()->IsTheHole()); | 798 ASSERT(cell->value()->IsTheHole()); |
| 803 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value(); | 799 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value(); |
| 804 if (Serializer::enabled()) { | 800 if (Serializer::enabled()) { |
| 805 __ mov(scratch, Immediate(cell)); | 801 __ mov(scratch, Immediate(cell)); |
| 806 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), | 802 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), |
| 807 Immediate(the_hole)); | 803 Immediate(the_hole)); |
| 808 } else { | 804 } else { |
| 809 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); | 805 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); |
| 810 } | 806 } |
| 811 __ j(not_equal, miss); | 807 __ j(not_equal, miss); |
| 812 } | 808 } |
| 813 | 809 |
| 814 | 810 |
| 815 void StoreStubCompiler::GenerateNegativeHolderLookup( | 811 void StoreStubCompiler::GenerateNegativeHolderLookup( |
| 816 MacroAssembler* masm, | 812 MacroAssembler* masm, |
| 817 Handle<JSObject> holder, | 813 Handle<JSObject> holder, |
| 818 Register holder_reg, | 814 Register holder_reg, |
| 819 Handle<Name> name, | 815 Handle<Name> name, |
| 820 Label* miss) { | 816 Label* miss) { |
| 821 if (holder->IsJSGlobalObject()) { | 817 if (holder->IsJSGlobalObject()) { |
| 822 GenerateCheckPropertyCell( | 818 GenerateCheckPropertyCell( |
| 823 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 819 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
| 824 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 820 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 825 GenerateDictionaryNegativeLookup( | 821 GenerateDictionaryNegativeLookup( |
| 826 masm, miss, holder_reg, name, scratch1(), scratch2()); | 822 masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 827 } | 823 } |
| 828 } | 824 } |
| 829 | 825 |
| 830 | 826 |
| 831 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if | 827 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if |
| 832 // store is successful. | 828 // store is successful. |
| 833 void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, | 829 void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 smi_check); | 1111 smi_check); |
| 1116 } | 1112 } |
| 1117 } | 1113 } |
| 1118 | 1114 |
| 1119 // Return the value (register eax). | 1115 // Return the value (register eax). |
| 1120 ASSERT(value_reg.is(eax)); | 1116 ASSERT(value_reg.is(eax)); |
| 1121 __ ret(0); | 1117 __ ret(0); |
| 1122 } | 1118 } |
| 1123 | 1119 |
| 1124 | 1120 |
| 1125 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1121 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1126 // from object to (but not including) holder. | 1122 Handle<JSObject> object, |
| 1127 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1123 Handle<JSObject> holder, |
| 1128 Handle<JSObject> object, | 1124 Handle<Name> name, |
| 1129 Handle<JSObject> holder, | 1125 Register scratch, |
| 1130 Handle<Name> name, | 1126 Label* miss) { |
| 1131 Register scratch, | |
| 1132 Label* miss) { | |
| 1133 Handle<JSObject> current = object; | 1127 Handle<JSObject> current = object; |
| 1134 while (!current.is_identical_to(holder)) { | 1128 while (!current.is_identical_to(holder)) { |
| 1135 if (current->IsGlobalObject()) { | 1129 if (current->IsJSGlobalObject()) { |
| 1136 GenerateCheckPropertyCell(masm, | 1130 GenerateCheckPropertyCell(masm, |
| 1137 Handle<GlobalObject>::cast(current), | 1131 Handle<JSGlobalObject>::cast(current), |
| 1138 name, | 1132 name, |
| 1139 scratch, | 1133 scratch, |
| 1140 miss); | 1134 miss); |
| 1141 } | 1135 } |
| 1142 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1136 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1143 } | 1137 } |
| 1144 } | 1138 } |
| 1145 | 1139 |
| 1146 | 1140 |
| 1147 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1141 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 } | 1342 } |
| 1349 __ cmp(scratch3(), callback); | 1343 __ cmp(scratch3(), callback); |
| 1350 __ j(not_equal, &miss); | 1344 __ j(not_equal, &miss); |
| 1351 } | 1345 } |
| 1352 | 1346 |
| 1353 HandlerFrontendFooter(name, success, &miss); | 1347 HandlerFrontendFooter(name, success, &miss); |
| 1354 return reg; | 1348 return reg; |
| 1355 } | 1349 } |
| 1356 | 1350 |
| 1357 | 1351 |
| 1358 void LoadStubCompiler::NonexistentHandlerFrontend( | |
| 1359 Handle<JSObject> object, | |
| 1360 Handle<JSObject> last, | |
| 1361 Handle<Name> name, | |
| 1362 Label* success, | |
| 1363 Handle<GlobalObject> global) { | |
| 1364 Label miss; | |
| 1365 | |
| 1366 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
| 1367 | |
| 1368 // If the last object in the prototype chain is a global object, | |
| 1369 // check that the global property cell is empty. | |
| 1370 if (!global.is_null()) { | |
| 1371 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
| 1372 } | |
| 1373 | |
| 1374 HandlerFrontendFooter(name, success, &miss); | |
| 1375 } | |
| 1376 | |
| 1377 | |
| 1378 void LoadStubCompiler::GenerateLoadField(Register reg, | 1352 void LoadStubCompiler::GenerateLoadField(Register reg, |
| 1379 Handle<JSObject> holder, | 1353 Handle<JSObject> holder, |
| 1380 PropertyIndex field, | 1354 PropertyIndex field, |
| 1381 Representation representation) { | 1355 Representation representation) { |
| 1382 if (!reg.is(receiver())) __ mov(receiver(), reg); | 1356 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1383 if (kind() == Code::LOAD_IC) { | 1357 if (kind() == Code::LOAD_IC) { |
| 1384 LoadFieldStub stub(field.is_inobject(holder), | 1358 LoadFieldStub stub(field.is_inobject(holder), |
| 1385 field.translate(holder), | 1359 field.translate(holder), |
| 1386 representation); | 1360 representation); |
| 1387 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1361 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3042 // Return the generated code. | 3016 // Return the generated code. |
| 3043 return GetICCode( | 3017 return GetICCode( |
| 3044 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | 3018 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
| 3045 } | 3019 } |
| 3046 | 3020 |
| 3047 | 3021 |
| 3048 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 3022 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
| 3049 Handle<JSObject> object, | 3023 Handle<JSObject> object, |
| 3050 Handle<JSObject> last, | 3024 Handle<JSObject> last, |
| 3051 Handle<Name> name, | 3025 Handle<Name> name, |
| 3052 Handle<GlobalObject> global) { | 3026 Handle<JSGlobalObject> global) { |
| 3053 Label success; | 3027 Label success; |
| 3054 | 3028 |
| 3055 NonexistentHandlerFrontend(object, last, name, &success, global); | 3029 NonexistentHandlerFrontend(object, last, name, &success, global); |
| 3056 | 3030 |
| 3057 __ bind(&success); | 3031 __ bind(&success); |
| 3058 // Return undefined if maps of the full prototype chain are still the | 3032 // Return undefined if maps of the full prototype chain are still the |
| 3059 // same and no global property with this name contains a value. | 3033 // same and no global property with this name contains a value. |
| 3060 __ mov(eax, isolate()->factory()->undefined_value()); | 3034 __ mov(eax, isolate()->factory()->undefined_value()); |
| 3061 __ ret(0); | 3035 __ ret(0); |
| 3062 | 3036 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3144 | 3118 |
| 3145 | 3119 |
| 3146 Handle<Code> LoadStubCompiler::CompileLoadGlobal( | 3120 Handle<Code> LoadStubCompiler::CompileLoadGlobal( |
| 3147 Handle<JSObject> object, | 3121 Handle<JSObject> object, |
| 3148 Handle<GlobalObject> global, | 3122 Handle<GlobalObject> global, |
| 3149 Handle<PropertyCell> cell, | 3123 Handle<PropertyCell> cell, |
| 3150 Handle<Name> name, | 3124 Handle<Name> name, |
| 3151 bool is_dont_delete) { | 3125 bool is_dont_delete) { |
| 3152 Label success, miss; | 3126 Label success, miss; |
| 3153 | 3127 |
| 3154 __ CheckMap(receiver(), Handle<Map>(object->map()), &miss, DO_SMI_CHECK); | 3128 HandlerFrontendHeader(object, receiver(), global, name, &miss); |
| 3155 HandlerFrontendHeader( | |
| 3156 object, receiver(), Handle<JSObject>::cast(global), name, &miss); | |
| 3157 // Get the value from the cell. | 3129 // Get the value from the cell. |
| 3158 if (Serializer::enabled()) { | 3130 if (Serializer::enabled()) { |
| 3159 __ mov(eax, Immediate(cell)); | 3131 __ mov(eax, Immediate(cell)); |
| 3160 __ mov(eax, FieldOperand(eax, PropertyCell::kValueOffset)); | 3132 __ mov(eax, FieldOperand(eax, PropertyCell::kValueOffset)); |
| 3161 } else { | 3133 } else { |
| 3162 __ mov(eax, Operand::ForCell(cell)); | 3134 __ mov(eax, Operand::ForCell(cell)); |
| 3163 } | 3135 } |
| 3164 | 3136 |
| 3165 // Check for deleted property if property can actually be deleted. | 3137 // Check for deleted property if property can actually be deleted. |
| 3166 if (!is_dont_delete) { | 3138 if (!is_dont_delete) { |
| 3167 __ cmp(eax, factory()->the_hole_value()); | 3139 __ cmp(eax, factory()->the_hole_value()); |
| 3168 __ j(equal, &miss); | 3140 __ j(equal, &miss); |
| 3169 } else if (FLAG_debug_code) { | 3141 } else if (FLAG_debug_code) { |
| 3170 __ cmp(eax, factory()->the_hole_value()); | 3142 __ cmp(eax, factory()->the_hole_value()); |
| 3171 __ Check(not_equal, kDontDeleteCellsCannotContainTheHole); | 3143 __ Check(not_equal, kDontDeleteCellsCannotContainTheHole); |
| 3172 } | 3144 } |
| 3173 | 3145 |
| 3174 HandlerFrontendFooter(name, &success, &miss); | 3146 HandlerFrontendFooter(name, &success, &miss); |
| 3175 __ bind(&success); | 3147 __ bind(&success); |
| 3176 | 3148 |
| 3177 Counters* counters = isolate()->counters(); | 3149 Counters* counters = isolate()->counters(); |
| 3178 __ IncrementCounter(counters->named_load_global_stub(), 1); | 3150 __ IncrementCounter(counters->named_load_global_stub(), 1); |
| 3179 // The code above already loads the result into the return register. | 3151 // The code above already loads the result into the return register. |
| 3180 __ ret(0); | 3152 __ ret(0); |
| 3181 | 3153 |
| 3182 // Return the generated code. | 3154 // Return the generated code. |
| 3183 return GetICCode(kind(), Code::NORMAL, name); | 3155 return GetCode(kind(), Code::NORMAL, name); |
| 3184 } | 3156 } |
| 3185 | 3157 |
| 3186 | 3158 |
| 3187 Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC( | 3159 Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC( |
| 3188 MapHandleList* receiver_maps, | 3160 MapHandleList* receiver_maps, |
| 3189 CodeHandleList* handlers, | 3161 CodeHandleList* handlers, |
| 3190 Handle<Name> name, | 3162 Handle<Name> name, |
| 3191 Code::StubType type, | 3163 Code::StubType type, |
| 3192 IcCheckType check) { | 3164 IcCheckType check) { |
| 3193 Label miss; | 3165 Label miss; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3267 // ----------------------------------- | 3239 // ----------------------------------- |
| 3268 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3240 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3269 } | 3241 } |
| 3270 | 3242 |
| 3271 | 3243 |
| 3272 #undef __ | 3244 #undef __ |
| 3273 | 3245 |
| 3274 } } // namespace v8::internal | 3246 } } // namespace v8::internal |
| 3275 | 3247 |
| 3276 #endif // V8_TARGET_ARCH_IA32 | 3248 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |