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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 #endif | 100 #endif |
101 | 101 |
102 // Jump to the first instruction in the code stub. | 102 // Jump to the first instruction in the code stub. |
103 __ addq(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 103 __ addq(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
104 __ jmp(kScratchRegister); | 104 __ jmp(kScratchRegister); |
105 | 105 |
106 __ bind(&miss); | 106 __ bind(&miss); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 // Helper function used to check that the dictionary doesn't contain | 110 void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
111 // the property. This function may return false negatives, so miss_label | 111 Label* miss_label, |
112 // must always call a backup property check that is complete. | 112 Register receiver, |
113 // This function is safe to call if the receiver has fast properties. | 113 Handle<Name> name, |
114 // Name must be unique and receiver must be a heap object. | 114 Register scratch0, |
115 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 115 Register scratch1) { |
116 Label* miss_label, | |
117 Register receiver, | |
118 Handle<Name> name, | |
119 Register r0, | |
120 Register r1) { | |
121 ASSERT(name->IsUniqueName()); | 116 ASSERT(name->IsUniqueName()); |
| 117 ASSERT(!receiver.is(scratch0)); |
122 Counters* counters = masm->isolate()->counters(); | 118 Counters* counters = masm->isolate()->counters(); |
123 __ IncrementCounter(counters->negative_lookups(), 1); | 119 __ IncrementCounter(counters->negative_lookups(), 1); |
124 __ IncrementCounter(counters->negative_lookups_miss(), 1); | 120 __ IncrementCounter(counters->negative_lookups_miss(), 1); |
125 | 121 |
126 __ movq(r0, FieldOperand(receiver, HeapObject::kMapOffset)); | 122 __ movq(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); |
127 | 123 |
128 const int kInterceptorOrAccessCheckNeededMask = | 124 const int kInterceptorOrAccessCheckNeededMask = |
129 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 125 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
130 | 126 |
131 // Bail out if the receiver has a named interceptor or requires access checks. | 127 // Bail out if the receiver has a named interceptor or requires access checks. |
132 __ testb(FieldOperand(r0, Map::kBitFieldOffset), | 128 __ testb(FieldOperand(scratch0, Map::kBitFieldOffset), |
133 Immediate(kInterceptorOrAccessCheckNeededMask)); | 129 Immediate(kInterceptorOrAccessCheckNeededMask)); |
134 __ j(not_zero, miss_label); | 130 __ j(not_zero, miss_label); |
135 | 131 |
136 // Check that receiver is a JSObject. | 132 // Check that receiver is a JSObject. |
137 __ CmpInstanceType(r0, FIRST_SPEC_OBJECT_TYPE); | 133 __ CmpInstanceType(scratch0, FIRST_SPEC_OBJECT_TYPE); |
138 __ j(below, miss_label); | 134 __ j(below, miss_label); |
139 | 135 |
140 // Load properties array. | 136 // Load properties array. |
141 Register properties = r0; | 137 Register properties = scratch0; |
142 __ movq(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); | 138 __ movq(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
143 | 139 |
144 // Check that the properties array is a dictionary. | 140 // Check that the properties array is a dictionary. |
145 __ CompareRoot(FieldOperand(properties, HeapObject::kMapOffset), | 141 __ CompareRoot(FieldOperand(properties, HeapObject::kMapOffset), |
146 Heap::kHashTableMapRootIndex); | 142 Heap::kHashTableMapRootIndex); |
147 __ j(not_equal, miss_label); | 143 __ j(not_equal, miss_label); |
148 | 144 |
149 Label done; | 145 Label done; |
150 NameDictionaryLookupStub::GenerateNegativeLookup(masm, | 146 NameDictionaryLookupStub::GenerateNegativeLookup(masm, |
151 miss_label, | 147 miss_label, |
152 &done, | 148 &done, |
153 properties, | 149 properties, |
154 name, | 150 name, |
155 r1); | 151 scratch1); |
156 __ bind(&done); | 152 __ bind(&done); |
157 __ DecrementCounter(counters->negative_lookups_miss(), 1); | 153 __ DecrementCounter(counters->negative_lookups_miss(), 1); |
158 } | 154 } |
159 | 155 |
160 | 156 |
161 void StubCache::GenerateProbe(MacroAssembler* masm, | 157 void StubCache::GenerateProbe(MacroAssembler* masm, |
162 Code::Flags flags, | 158 Code::Flags flags, |
163 Register receiver, | 159 Register receiver, |
164 Register name, | 160 Register name, |
165 Register scratch, | 161 Register scratch, |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, | 762 void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, |
767 Label* label, | 763 Label* label, |
768 Handle<Name> name) { | 764 Handle<Name> name) { |
769 if (!label->is_unused()) { | 765 if (!label->is_unused()) { |
770 __ bind(label); | 766 __ bind(label); |
771 __ Move(this->name(), name); | 767 __ Move(this->name(), name); |
772 } | 768 } |
773 } | 769 } |
774 | 770 |
775 | 771 |
776 // Generate code to check that a global property cell is empty. Create | 772 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
777 // the property cell at compilation time if no cell exists for the | 773 Handle<JSGlobalObject> global, |
778 // property. | 774 Handle<Name> name, |
779 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 775 Register scratch, |
780 Handle<GlobalObject> global, | 776 Label* miss) { |
781 Handle<Name> name, | |
782 Register scratch, | |
783 Label* miss) { | |
784 Handle<PropertyCell> cell = | 777 Handle<PropertyCell> cell = |
785 GlobalObject::EnsurePropertyCell(global, name); | 778 JSGlobalObject::EnsurePropertyCell(global, name); |
786 ASSERT(cell->value()->IsTheHole()); | 779 ASSERT(cell->value()->IsTheHole()); |
787 __ Move(scratch, cell); | 780 __ Move(scratch, cell); |
788 __ Cmp(FieldOperand(scratch, Cell::kValueOffset), | 781 __ Cmp(FieldOperand(scratch, Cell::kValueOffset), |
789 masm->isolate()->factory()->the_hole_value()); | 782 masm->isolate()->factory()->the_hole_value()); |
790 __ j(not_equal, miss); | 783 __ j(not_equal, miss); |
791 } | 784 } |
792 | 785 |
793 | 786 |
794 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( | 787 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( |
795 MacroAssembler* masm, | 788 MacroAssembler* masm, |
796 Handle<JSObject> holder, | 789 Handle<JSObject> holder, |
797 Register holder_reg, | 790 Register holder_reg, |
798 Handle<Name> name, | 791 Handle<Name> name, |
799 Label* miss) { | 792 Label* miss) { |
800 if (holder->IsJSGlobalObject()) { | 793 if (holder->IsJSGlobalObject()) { |
801 GenerateCheckPropertyCell( | 794 GenerateCheckPropertyCell( |
802 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 795 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
803 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 796 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
804 GenerateDictionaryNegativeLookup( | 797 GenerateDictionaryNegativeLookup( |
805 masm, miss, holder_reg, name, scratch1(), scratch2()); | 798 masm, miss, holder_reg, name, scratch1(), scratch2()); |
806 } | 799 } |
807 } | 800 } |
808 | 801 |
809 | 802 |
810 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if | 803 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if |
811 // store is successful. | 804 // store is successful. |
812 void BaseStoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, | 805 void BaseStoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 EMIT_REMEMBERED_SET, smi_check); | 1036 EMIT_REMEMBERED_SET, smi_check); |
1044 } | 1037 } |
1045 } | 1038 } |
1046 | 1039 |
1047 // Return the value (register rax). | 1040 // Return the value (register rax). |
1048 ASSERT(value_reg.is(rax)); | 1041 ASSERT(value_reg.is(rax)); |
1049 __ ret(0); | 1042 __ ret(0); |
1050 } | 1043 } |
1051 | 1044 |
1052 | 1045 |
1053 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1046 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
1054 // from object to (but not including) holder. | 1047 Handle<JSObject> object, |
1055 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1048 Handle<JSObject> holder, |
1056 Handle<JSObject> object, | 1049 Handle<Name> name, |
1057 Handle<JSObject> holder, | 1050 Register scratch, |
1058 Handle<Name> name, | 1051 Label* miss) { |
1059 Register scratch, | |
1060 Label* miss) { | |
1061 Handle<JSObject> current = object; | 1052 Handle<JSObject> current = object; |
1062 while (!current.is_identical_to(holder)) { | 1053 while (!current.is_identical_to(holder)) { |
1063 if (current->IsGlobalObject()) { | 1054 if (current->IsJSGlobalObject()) { |
1064 GenerateCheckPropertyCell(masm, | 1055 GenerateCheckPropertyCell(masm, |
1065 Handle<GlobalObject>::cast(current), | 1056 Handle<JSGlobalObject>::cast(current), |
1066 name, | 1057 name, |
1067 scratch, | 1058 scratch, |
1068 miss); | 1059 miss); |
1069 } | 1060 } |
1070 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1061 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
1071 } | 1062 } |
1072 } | 1063 } |
1073 | 1064 |
1074 | 1065 |
1075 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1066 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 __ movq(scratch3(), callback, RelocInfo::EMBEDDED_OBJECT); | 1257 __ movq(scratch3(), callback, RelocInfo::EMBEDDED_OBJECT); |
1267 __ cmpq(scratch2(), scratch3()); | 1258 __ cmpq(scratch2(), scratch3()); |
1268 __ j(not_equal, &miss); | 1259 __ j(not_equal, &miss); |
1269 } | 1260 } |
1270 | 1261 |
1271 HandlerFrontendFooter(name, success, &miss); | 1262 HandlerFrontendFooter(name, success, &miss); |
1272 return reg; | 1263 return reg; |
1273 } | 1264 } |
1274 | 1265 |
1275 | 1266 |
1276 void BaseLoadStubCompiler::NonexistentHandlerFrontend( | |
1277 Handle<JSObject> object, | |
1278 Handle<JSObject> last, | |
1279 Handle<Name> name, | |
1280 Label* success, | |
1281 Handle<GlobalObject> global) { | |
1282 Label miss; | |
1283 | |
1284 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
1285 | |
1286 // If the last object in the prototype chain is a global object, | |
1287 // check that the global property cell is empty. | |
1288 if (!global.is_null()) { | |
1289 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
1290 } | |
1291 | |
1292 HandlerFrontendFooter(name, success, &miss); | |
1293 } | |
1294 | |
1295 | |
1296 void BaseLoadStubCompiler::GenerateLoadField(Register reg, | 1267 void BaseLoadStubCompiler::GenerateLoadField(Register reg, |
1297 Handle<JSObject> holder, | 1268 Handle<JSObject> holder, |
1298 PropertyIndex field, | 1269 PropertyIndex field, |
1299 Representation representation) { | 1270 Representation representation) { |
1300 if (!reg.is(receiver())) __ movq(receiver(), reg); | 1271 if (!reg.is(receiver())) __ movq(receiver(), reg); |
1301 if (kind() == Code::LOAD_IC) { | 1272 if (kind() == Code::LOAD_IC) { |
1302 LoadFieldStub stub(field.is_inobject(holder), | 1273 LoadFieldStub stub(field.is_inobject(holder), |
1303 field.translate(holder), | 1274 field.translate(holder), |
1304 representation); | 1275 representation); |
1305 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1276 GenerateTailCall(masm(), stub.GetCode(isolate())); |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2934 // Return the generated code. | 2905 // Return the generated code. |
2935 return GetICCode( | 2906 return GetICCode( |
2936 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | 2907 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
2937 } | 2908 } |
2938 | 2909 |
2939 | 2910 |
2940 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 2911 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
2941 Handle<JSObject> object, | 2912 Handle<JSObject> object, |
2942 Handle<JSObject> last, | 2913 Handle<JSObject> last, |
2943 Handle<Name> name, | 2914 Handle<Name> name, |
2944 Handle<GlobalObject> global) { | 2915 Handle<JSGlobalObject> global) { |
2945 Label success; | 2916 Label success; |
2946 | 2917 |
2947 NonexistentHandlerFrontend(object, last, name, &success, global); | 2918 NonexistentHandlerFrontend(object, last, name, &success, global); |
2948 | 2919 |
2949 __ bind(&success); | 2920 __ bind(&success); |
2950 // Return undefined if maps of the full prototype chain are still the | 2921 // Return undefined if maps of the full prototype chain are still the |
2951 // same and no global property with this name contains a value. | 2922 // same and no global property with this name contains a value. |
2952 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 2923 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
2953 __ ret(0); | 2924 __ ret(0); |
2954 | 2925 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3162 // ----------------------------------- | 3133 // ----------------------------------- |
3163 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3134 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
3164 } | 3135 } |
3165 | 3136 |
3166 | 3137 |
3167 #undef __ | 3138 #undef __ |
3168 | 3139 |
3169 } } // namespace v8::internal | 3140 } } // namespace v8::internal |
3170 | 3141 |
3171 #endif // V8_TARGET_ARCH_X64 | 3142 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |