Chromium Code Reviews| 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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 // This function is used for both construct and normal calls of Array. Whether | 1081 // This function is used for both construct and normal calls of Array. Whether |
| 1082 // it is a construct call or not is indicated by the construct_call parameter. | 1082 // it is a construct call or not is indicated by the construct_call parameter. |
| 1083 // The only difference between handling a construct call and a normal call is | 1083 // The only difference between handling a construct call and a normal call is |
| 1084 // that for a construct call the constructor function in edi needs to be | 1084 // that for a construct call the constructor function in edi needs to be |
| 1085 // preserved for entering the generic code. In both cases argc in eax needs to | 1085 // preserved for entering the generic code. In both cases argc in eax needs to |
| 1086 // be preserved. | 1086 // be preserved. |
| 1087 static void ArrayNativeCode(MacroAssembler* masm, | 1087 static void ArrayNativeCode(MacroAssembler* masm, |
| 1088 bool construct_call, | 1088 bool construct_call, |
| 1089 Label* call_generic_code) { | 1089 Label* call_generic_code) { |
| 1090 Label argc_one_or_more, argc_two_or_more, prepare_generic_code_call, | 1090 Label argc_one_or_more, argc_two_or_more, prepare_generic_code_call, |
| 1091 empty_array, not_empty_array; | 1091 empty_array, not_empty_array, finish, cant_transition_map, not_double; |
| 1092 | 1092 |
| 1093 // Push the constructor and argc. No need to tag argc as a smi, as there will | 1093 // Push the constructor and argc. No need to tag argc as a smi, as there will |
| 1094 // be no garbage collection with this on the stack. | 1094 // be no garbage collection with this on the stack. |
| 1095 int push_count = 0; | 1095 int push_count = 0; |
| 1096 if (construct_call) { | 1096 if (construct_call) { |
| 1097 push_count++; | 1097 push_count++; |
| 1098 __ push(edi); | 1098 __ push(edi); |
| 1099 } | 1099 } |
| 1100 push_count++; | 1100 push_count++; |
| 1101 __ push(eax); | 1101 __ push(eax); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 __ jmp(&entry); | 1231 __ jmp(&entry); |
| 1232 __ bind(&loop); | 1232 __ bind(&loop); |
| 1233 __ mov(eax, Operand(edi, ecx, times_pointer_size, 0)); | 1233 __ mov(eax, Operand(edi, ecx, times_pointer_size, 0)); |
| 1234 if (FLAG_smi_only_arrays) { | 1234 if (FLAG_smi_only_arrays) { |
| 1235 __ JumpIfNotSmi(eax, &has_non_smi_element); | 1235 __ JumpIfNotSmi(eax, &has_non_smi_element); |
| 1236 } | 1236 } |
| 1237 __ mov(Operand(edx, 0), eax); | 1237 __ mov(Operand(edx, 0), eax); |
| 1238 __ add(edx, Immediate(kPointerSize)); | 1238 __ add(edx, Immediate(kPointerSize)); |
| 1239 __ bind(&entry); | 1239 __ bind(&entry); |
| 1240 __ dec(ecx); | 1240 __ dec(ecx); |
| 1241 __ j(greater_equal, &loop); | 1241 __ j(greater_equal, &loop, Label::kNear); |
| 1242 | 1242 |
| 1243 // Remove caller arguments from the stack and return. | 1243 // Remove caller arguments from the stack and return. |
| 1244 // ebx: argc | 1244 // ebx: argc |
| 1245 // esp[0]: JSArray | 1245 // esp[0]: JSArray |
| 1246 // esp[4]: argc | 1246 // esp[4]: argc |
| 1247 // esp[8]: constructor (only if construct_call) | 1247 // esp[8]: constructor (only if construct_call) |
| 1248 // esp[12]: return address | 1248 // esp[12]: return address |
| 1249 // esp[16]: last argument | 1249 // esp[16]: last argument |
| 1250 __ bind(&finish); | |
| 1250 __ mov(ecx, Operand(esp, last_arg_offset - kPointerSize)); | 1251 __ mov(ecx, Operand(esp, last_arg_offset - kPointerSize)); |
| 1251 __ pop(eax); | 1252 __ pop(eax); |
| 1252 __ pop(ebx); | 1253 __ pop(ebx); |
| 1253 __ lea(esp, Operand(esp, ebx, times_pointer_size, | 1254 __ lea(esp, Operand(esp, ebx, times_pointer_size, |
| 1254 last_arg_offset - kPointerSize)); | 1255 last_arg_offset - kPointerSize)); |
| 1255 __ jmp(ecx); | 1256 __ jmp(ecx); |
| 1256 | 1257 |
| 1257 __ bind(&has_non_smi_element); | 1258 __ bind(&has_non_smi_element); |
| 1259 // Double values are handled by the runtime. | |
| 1260 __ CheckMap(eax, | |
| 1261 masm->isolate()->factory()->heap_number_map(), | |
| 1262 ¬_double, | |
| 1263 DONT_DO_SMI_CHECK); | |
| 1264 __ bind(&cant_transition_map); | |
| 1258 // Throw away the array that's only been partially constructed. | 1265 // Throw away the array that's only been partially constructed. |
| 1259 __ pop(eax); | 1266 __ pop(eax); |
| 1260 __ UndoAllocationInNewSpace(eax); | 1267 __ UndoAllocationInNewSpace(eax); |
| 1268 __ jmp(&prepare_generic_code_call); | |
| 1269 | |
| 1270 __ bind(¬_double); | |
| 1271 // Transition FAST_SMI_ONLY_ELEMENTS to FAST_ELEMENTS | |
| 1272 __ mov(ebx, Operand(esp, 0)); | |
| 1273 __ mov(edi, FieldOperand(ebx, HeapObject::kMapOffset)); | |
| 1274 __ LoadTransitionedArrayMapConditional( | |
| 1275 FAST_SMI_ONLY_ELEMENTS, | |
| 1276 FAST_ELEMENTS, | |
| 1277 edi, | |
| 1278 eax, | |
| 1279 &cant_transition_map); | |
| 1280 __ mov(FieldOperand(ebx, HeapObject::kMapOffset), edi); | |
| 1281 __ RecordWriteField(ebx, HeapObject::kMapOffset, edi, eax, | |
|
Yang
2012/02/10 10:25:14
where does the value of eax come from?
| |
| 1282 kDontSaveFPRegs, OMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
| 1283 | |
| 1284 // Prepare to re-enter the loop | |
| 1285 __ lea(edi, Operand(esp, last_arg_offset)); | |
| 1286 | |
| 1287 // Finish the array initialization loop. | |
| 1288 Label loop2; | |
| 1289 __ bind(&loop2); | |
| 1290 __ mov(eax, Operand(edi, ecx, times_pointer_size, 0)); | |
| 1291 __ mov(Operand(edx, 0), eax); | |
| 1292 __ add(edx, Immediate(kPointerSize)); | |
| 1293 __ dec(ecx); | |
| 1294 __ j(greater_equal, &loop2, Label::kNear); | |
| 1295 __ jmp(&finish); | |
| 1261 | 1296 |
| 1262 // Restore argc and constructor before running the generic code. | 1297 // Restore argc and constructor before running the generic code. |
| 1263 __ bind(&prepare_generic_code_call); | 1298 __ bind(&prepare_generic_code_call); |
| 1264 __ pop(eax); | 1299 __ pop(eax); |
| 1265 if (construct_call) { | 1300 if (construct_call) { |
| 1266 __ pop(edi); | 1301 __ pop(edi); |
| 1267 } | 1302 } |
| 1268 __ jmp(call_generic_code); | 1303 __ jmp(call_generic_code); |
| 1269 } | 1304 } |
| 1270 | 1305 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1685 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1720 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1686 generator.Generate(); | 1721 generator.Generate(); |
| 1687 } | 1722 } |
| 1688 | 1723 |
| 1689 | 1724 |
| 1690 #undef __ | 1725 #undef __ |
| 1691 } | 1726 } |
| 1692 } // namespace v8::internal | 1727 } // namespace v8::internal |
| 1693 | 1728 |
| 1694 #endif // V8_TARGET_ARCH_IA32 | 1729 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |