| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1123 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1124 // Cache the called function in a feedback vector slot. Cache states | 1124 // Cache the called function in a feedback vector slot. Cache states |
| 1125 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1125 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1126 // megamorphic. | 1126 // megamorphic. |
| 1127 // eax : number of arguments to the construct function | 1127 // eax : number of arguments to the construct function |
| 1128 // ebx : feedback vector | 1128 // ebx : feedback vector |
| 1129 // edx : slot in feedback vector (Smi) | 1129 // edx : slot in feedback vector (Smi) |
| 1130 // edi : the function to call | 1130 // edi : the function to call |
| 1131 Isolate* isolate = masm->isolate(); | 1131 Isolate* isolate = masm->isolate(); |
| 1132 Label initialize, done, miss, megamorphic, not_array_function; | 1132 Label initialize, done, miss, megamorphic, not_array_function; |
| 1133 Label done_increment_count, done_initialize_count; | |
| 1134 | 1133 |
| 1135 // Load the cache state into ecx. | 1134 // Load the cache state into ecx. |
| 1136 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1135 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 1137 FixedArray::kHeaderSize)); | 1136 FixedArray::kHeaderSize)); |
| 1138 | 1137 |
| 1139 // A monomorphic cache hit or an already megamorphic state: invoke the | 1138 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1140 // function without changing the state. | 1139 // function without changing the state. |
| 1141 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read | 1140 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read |
| 1142 // at this position in a symbol (see static asserts in | 1141 // at this position in a symbol (see static asserts in |
| 1143 // type-feedback-vector.h). | 1142 // type-feedback-vector.h). |
| 1144 Label check_allocation_site; | 1143 Label check_allocation_site; |
| 1145 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); | 1144 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
| 1146 __ j(equal, &done_increment_count, Label::kFar); | 1145 __ j(equal, &done, Label::kFar); |
| 1147 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); | 1146 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); |
| 1148 __ j(equal, &done, Label::kFar); | 1147 __ j(equal, &done, Label::kFar); |
| 1149 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), | 1148 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), |
| 1150 Heap::kWeakCellMapRootIndex); | 1149 Heap::kWeakCellMapRootIndex); |
| 1151 __ j(not_equal, &check_allocation_site); | 1150 __ j(not_equal, &check_allocation_site); |
| 1152 | 1151 |
| 1153 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1152 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1154 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); | 1153 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); |
| 1155 __ jmp(&megamorphic); | 1154 __ jmp(&megamorphic); |
| 1156 | 1155 |
| 1157 __ bind(&check_allocation_site); | 1156 __ bind(&check_allocation_site); |
| 1158 // If we came here, we need to see if we are the array function. | 1157 // If we came here, we need to see if we are the array function. |
| 1159 // If we didn't have a matching function, and we didn't find the megamorph | 1158 // If we didn't have a matching function, and we didn't find the megamorph |
| 1160 // sentinel, then we have in the slot either some other function or an | 1159 // sentinel, then we have in the slot either some other function or an |
| 1161 // AllocationSite. | 1160 // AllocationSite. |
| 1162 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); | 1161 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); |
| 1163 __ j(not_equal, &miss); | 1162 __ j(not_equal, &miss); |
| 1164 | 1163 |
| 1165 // Make sure the function is the Array() function | 1164 // Make sure the function is the Array() function |
| 1166 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1165 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
| 1167 __ cmp(edi, ecx); | 1166 __ cmp(edi, ecx); |
| 1168 __ j(not_equal, &megamorphic); | 1167 __ j(not_equal, &megamorphic); |
| 1169 __ jmp(&done_increment_count, Label::kFar); | 1168 __ jmp(&done, Label::kFar); |
| 1170 | 1169 |
| 1171 __ bind(&miss); | 1170 __ bind(&miss); |
| 1172 | 1171 |
| 1173 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1172 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1174 // megamorphic. | 1173 // megamorphic. |
| 1175 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); | 1174 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); |
| 1176 __ j(equal, &initialize); | 1175 __ j(equal, &initialize); |
| 1177 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1176 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1178 // write-barrier is needed. | 1177 // write-barrier is needed. |
| 1179 __ bind(&megamorphic); | 1178 __ bind(&megamorphic); |
| 1180 __ mov( | 1179 __ mov( |
| 1181 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1180 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
| 1182 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1181 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
| 1183 __ jmp(&done, Label::kFar); | 1182 __ jmp(&done, Label::kFar); |
| 1184 | 1183 |
| 1185 // An uninitialized cache is patched with the function or sentinel to | 1184 // An uninitialized cache is patched with the function or sentinel to |
| 1186 // indicate the ElementsKind if function is the Array constructor. | 1185 // indicate the ElementsKind if function is the Array constructor. |
| 1187 __ bind(&initialize); | 1186 __ bind(&initialize); |
| 1188 // Make sure the function is the Array() function | 1187 // Make sure the function is the Array() function |
| 1189 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1188 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
| 1190 __ cmp(edi, ecx); | 1189 __ cmp(edi, ecx); |
| 1191 __ j(not_equal, ¬_array_function); | 1190 __ j(not_equal, ¬_array_function); |
| 1192 | 1191 |
| 1193 // The target function is the Array constructor, | 1192 // The target function is the Array constructor, |
| 1194 // Create an AllocationSite if we don't already have it, store it in the | 1193 // Create an AllocationSite if we don't already have it, store it in the |
| 1195 // slot. | 1194 // slot. |
| 1196 CreateAllocationSiteStub create_stub(isolate); | 1195 CreateAllocationSiteStub create_stub(isolate); |
| 1197 CallStubInRecordCallTarget(masm, &create_stub); | 1196 CallStubInRecordCallTarget(masm, &create_stub); |
| 1198 __ jmp(&done_initialize_count); | 1197 __ jmp(&done); |
| 1199 | 1198 |
| 1200 __ bind(¬_array_function); | 1199 __ bind(¬_array_function); |
| 1201 CreateWeakCellStub weak_cell_stub(isolate); | 1200 CreateWeakCellStub weak_cell_stub(isolate); |
| 1202 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1201 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1203 __ bind(&done_initialize_count); | |
| 1204 | 1202 |
| 1205 // Initialize the call counter. | 1203 __ bind(&done); |
| 1206 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | 1204 // Increment the call count for all function calls. |
| 1207 FixedArray::kHeaderSize + kPointerSize), | |
| 1208 Immediate(Smi::FromInt(1))); | |
| 1209 __ jmp(&done); | |
| 1210 | |
| 1211 __ bind(&done_increment_count); | |
| 1212 // Increment the call count for monomorphic function calls. | |
| 1213 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1205 __ add(FieldOperand(ebx, edx, times_half_pointer_size, |
| 1214 FixedArray::kHeaderSize + kPointerSize), | 1206 FixedArray::kHeaderSize + kPointerSize), |
| 1215 Immediate(Smi::FromInt(1))); | 1207 Immediate(Smi::FromInt(1))); |
| 1216 | |
| 1217 __ bind(&done); | |
| 1218 } | 1208 } |
| 1219 | 1209 |
| 1220 | 1210 |
| 1221 void CallConstructStub::Generate(MacroAssembler* masm) { | 1211 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1222 // eax : number of arguments | 1212 // eax : number of arguments |
| 1223 // ebx : feedback vector | 1213 // ebx : feedback vector |
| 1224 // edx : slot in feedback vector (Smi, for RecordCallTarget) | 1214 // edx : slot in feedback vector (Smi, for RecordCallTarget) |
| 1225 // edi : constructor function | 1215 // edi : constructor function |
| 1226 | 1216 |
| 1227 Label non_function; | 1217 Label non_function; |
| (...skipping 4030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5258 kStackUnwindSpace, nullptr, return_value_operand, | 5248 kStackUnwindSpace, nullptr, return_value_operand, |
| 5259 NULL); | 5249 NULL); |
| 5260 } | 5250 } |
| 5261 | 5251 |
| 5262 #undef __ | 5252 #undef __ |
| 5263 | 5253 |
| 5264 } // namespace internal | 5254 } // namespace internal |
| 5265 } // namespace v8 | 5255 } // namespace v8 |
| 5266 | 5256 |
| 5267 #endif // V8_TARGET_ARCH_X87 | 5257 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |