OLD | NEW |
1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 // rsp[0]: return address | 1192 // rsp[0]: return address |
1193 // rsp[8]: last argument | 1193 // rsp[8]: last argument |
1194 // This function is used for both construct and normal calls of Array. The only | 1194 // This function is used for both construct and normal calls of Array. The only |
1195 // difference between handling a construct call and a normal call is that for a | 1195 // difference between handling a construct call and a normal call is that for a |
1196 // construct call the constructor function in rdi needs to be preserved for | 1196 // construct call the constructor function in rdi needs to be preserved for |
1197 // entering the generic code. In both cases argc in rax needs to be preserved. | 1197 // entering the generic code. In both cases argc in rax needs to be preserved. |
1198 // Both registers are preserved by this code so no need to differentiate between | 1198 // Both registers are preserved by this code so no need to differentiate between |
1199 // a construct call and a normal call. | 1199 // a construct call and a normal call. |
1200 static void ArrayNativeCode(MacroAssembler* masm, | 1200 static void ArrayNativeCode(MacroAssembler* masm, |
1201 Label *call_generic_code) { | 1201 Label *call_generic_code) { |
1202 Label argc_one_or_more, argc_two_or_more, empty_array, not_empty_array; | 1202 Label argc_one_or_more, argc_two_or_more, empty_array, not_empty_array, |
| 1203 has_non_smi_element; |
1203 | 1204 |
1204 // Check for array construction with zero arguments. | 1205 // Check for array construction with zero arguments. |
1205 __ testq(rax, rax); | 1206 __ testq(rax, rax); |
1206 __ j(not_zero, &argc_one_or_more); | 1207 __ j(not_zero, &argc_one_or_more); |
1207 | 1208 |
1208 __ bind(&empty_array); | 1209 __ bind(&empty_array); |
1209 // Handle construction of an empty array. | 1210 // Handle construction of an empty array. |
1210 AllocateEmptyJSArray(masm, | 1211 AllocateEmptyJSArray(masm, |
1211 rdi, | 1212 rdi, |
1212 rbx, | 1213 rbx, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 // rdx: location of the first array element | 1300 // rdx: location of the first array element |
1300 // r9: location of the last argument | 1301 // r9: location of the last argument |
1301 // esp[0]: return address | 1302 // esp[0]: return address |
1302 // esp[8]: last argument | 1303 // esp[8]: last argument |
1303 Label loop, entry; | 1304 Label loop, entry; |
1304 __ movq(rcx, rax); | 1305 __ movq(rcx, rax); |
1305 __ jmp(&entry); | 1306 __ jmp(&entry); |
1306 __ bind(&loop); | 1307 __ bind(&loop); |
1307 __ movq(kScratchRegister, Operand(r9, rcx, times_pointer_size, 0)); | 1308 __ movq(kScratchRegister, Operand(r9, rcx, times_pointer_size, 0)); |
1308 if (FLAG_smi_only_arrays) { | 1309 if (FLAG_smi_only_arrays) { |
1309 __ JumpIfNotSmi(kScratchRegister, call_generic_code); | 1310 __ JumpIfNotSmi(kScratchRegister, &has_non_smi_element); |
1310 } | 1311 } |
1311 __ movq(Operand(rdx, 0), kScratchRegister); | 1312 __ movq(Operand(rdx, 0), kScratchRegister); |
1312 __ addq(rdx, Immediate(kPointerSize)); | 1313 __ addq(rdx, Immediate(kPointerSize)); |
1313 __ bind(&entry); | 1314 __ bind(&entry); |
1314 __ decq(rcx); | 1315 __ decq(rcx); |
1315 __ j(greater_equal, &loop); | 1316 __ j(greater_equal, &loop); |
1316 | 1317 |
1317 // Remove caller arguments from the stack and return. | 1318 // Remove caller arguments from the stack and return. |
1318 // rax: argc | 1319 // rax: argc |
1319 // rbx: JSArray | 1320 // rbx: JSArray |
1320 // esp[0]: return address | 1321 // esp[0]: return address |
1321 // esp[8]: last argument | 1322 // esp[8]: last argument |
1322 __ pop(rcx); | 1323 __ pop(rcx); |
1323 __ lea(rsp, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 1324 __ lea(rsp, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); |
1324 __ push(rcx); | 1325 __ push(rcx); |
1325 __ movq(rax, rbx); | 1326 __ movq(rax, rbx); |
1326 __ ret(0); | 1327 __ ret(0); |
| 1328 |
| 1329 __ bind(&has_non_smi_element); |
| 1330 __ UndoAllocationInNewSpace(rbx); |
| 1331 __ jmp(call_generic_code); |
1327 } | 1332 } |
1328 | 1333 |
1329 | 1334 |
1330 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 1335 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
1331 // ----------- S t a t e ------------- | 1336 // ----------- S t a t e ------------- |
1332 // -- rax : argc | 1337 // -- rax : argc |
1333 // -- rsp[0] : return address | 1338 // -- rsp[0] : return address |
1334 // -- rsp[8] : last argument | 1339 // -- rsp[8] : last argument |
1335 // ----------------------------------- | 1340 // ----------------------------------- |
1336 Label generic_array_code; | 1341 Label generic_array_code; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1616 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1612 generator.Generate(); | 1617 generator.Generate(); |
1613 } | 1618 } |
1614 | 1619 |
1615 | 1620 |
1616 #undef __ | 1621 #undef __ |
1617 | 1622 |
1618 } } // namespace v8::internal | 1623 } } // namespace v8::internal |
1619 | 1624 |
1620 #endif // V8_TARGET_ARCH_X64 | 1625 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |