OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // sp[0]: last argument | 317 // sp[0]: last argument |
318 // This function is used for both construct and normal calls of Array. The only | 318 // This function is used for both construct and normal calls of Array. The only |
319 // difference between handling a construct call and a normal call is that for a | 319 // difference between handling a construct call and a normal call is that for a |
320 // construct call the constructor function in a1 needs to be preserved for | 320 // construct call the constructor function in a1 needs to be preserved for |
321 // entering the generic code. In both cases argc in a0 needs to be preserved. | 321 // entering the generic code. In both cases argc in a0 needs to be preserved. |
322 // Both registers are preserved by this code so no need to differentiate between | 322 // Both registers are preserved by this code so no need to differentiate between |
323 // construct call and normal call. | 323 // construct call and normal call. |
324 static void ArrayNativeCode(MacroAssembler* masm, | 324 static void ArrayNativeCode(MacroAssembler* masm, |
325 Label* call_generic_code) { | 325 Label* call_generic_code) { |
326 Counters* counters = masm->isolate()->counters(); | 326 Counters* counters = masm->isolate()->counters(); |
327 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array; | 327 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array, |
| 328 has_non_smi_element; |
328 | 329 |
329 // Check for array construction with zero arguments or one. | 330 // Check for array construction with zero arguments or one. |
330 __ Branch(&argc_one_or_more, ne, a0, Operand(zero_reg)); | 331 __ Branch(&argc_one_or_more, ne, a0, Operand(zero_reg)); |
331 // Handle construction of an empty array. | 332 // Handle construction of an empty array. |
332 __ bind(&empty_array); | 333 __ bind(&empty_array); |
333 AllocateEmptyJSArray(masm, | 334 AllocateEmptyJSArray(masm, |
334 a1, | 335 a1, |
335 a2, | 336 a2, |
336 a3, | 337 a3, |
337 t0, | 338 t0, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // t1: elements_array_end (untagged) | 416 // t1: elements_array_end (untagged) |
416 // sp[0]: last argument | 417 // sp[0]: last argument |
417 | 418 |
418 Label loop, entry; | 419 Label loop, entry; |
419 __ Branch(USE_DELAY_SLOT, &entry); | 420 __ Branch(USE_DELAY_SLOT, &entry); |
420 __ mov(t3, sp); | 421 __ mov(t3, sp); |
421 __ bind(&loop); | 422 __ bind(&loop); |
422 __ lw(a2, MemOperand(t3)); | 423 __ lw(a2, MemOperand(t3)); |
423 __ Addu(t3, t3, kPointerSize); | 424 __ Addu(t3, t3, kPointerSize); |
424 if (FLAG_smi_only_arrays) { | 425 if (FLAG_smi_only_arrays) { |
425 __ JumpIfNotSmi(a2, call_generic_code); | 426 __ JumpIfNotSmi(a2, &has_non_smi_element); |
426 } | 427 } |
427 __ Addu(t1, t1, -kPointerSize); | 428 __ Addu(t1, t1, -kPointerSize); |
428 __ sw(a2, MemOperand(t1)); | 429 __ sw(a2, MemOperand(t1)); |
429 __ bind(&entry); | 430 __ bind(&entry); |
430 __ Branch(&loop, lt, t0, Operand(t1)); | 431 __ Branch(&loop, lt, t0, Operand(t1)); |
431 __ mov(sp, t3); | 432 __ mov(sp, t3); |
432 | 433 |
433 // Remove caller arguments and receiver from the stack, setup return value and | 434 // Remove caller arguments and receiver from the stack, setup return value and |
434 // return. | 435 // return. |
435 // a0: argc | 436 // a0: argc |
436 // a3: JSArray | 437 // a3: JSArray |
437 // sp[0]: receiver | 438 // sp[0]: receiver |
438 __ Addu(sp, sp, Operand(kPointerSize)); | 439 __ Addu(sp, sp, Operand(kPointerSize)); |
439 __ mov(v0, a3); | 440 __ mov(v0, a3); |
440 __ Ret(); | 441 __ Ret(); |
| 442 |
| 443 __ bind(&has_non_smi_element); |
| 444 __ UndoAllocationInNewSpace(a3, t0); |
| 445 __ b(call_generic_code); |
441 } | 446 } |
442 | 447 |
443 | 448 |
444 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 449 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
445 // ----------- S t a t e ------------- | 450 // ----------- S t a t e ------------- |
446 // -- a0 : number of arguments | 451 // -- a0 : number of arguments |
447 // -- ra : return address | 452 // -- ra : return address |
448 // -- sp[...]: constructor arguments | 453 // -- sp[...]: constructor arguments |
449 // ----------------------------------- | 454 // ----------------------------------- |
450 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; | 455 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; |
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 __ bind(&dont_adapt_arguments); | 1814 __ bind(&dont_adapt_arguments); |
1810 __ Jump(a3); | 1815 __ Jump(a3); |
1811 } | 1816 } |
1812 | 1817 |
1813 | 1818 |
1814 #undef __ | 1819 #undef __ |
1815 | 1820 |
1816 } } // namespace v8::internal | 1821 } } // namespace v8::internal |
1817 | 1822 |
1818 #endif // V8_TARGET_ARCH_MIPS | 1823 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |