OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 // Check for one argument. Bail out if argument is not smi or if it is | 930 // Check for one argument. Bail out if argument is not smi or if it is |
931 // negative. | 931 // negative. |
932 __ bind(&argc_one_or_more); | 932 __ bind(&argc_one_or_more); |
933 __ cmp(eax, 1); | 933 __ cmp(eax, 1); |
934 __ j(not_equal, &argc_two_or_more); | 934 __ j(not_equal, &argc_two_or_more); |
935 ASSERT(kSmiTag == 0); | 935 ASSERT(kSmiTag == 0); |
936 __ mov(ecx, Operand(esp, (push_count + 1) * kPointerSize)); | 936 __ mov(ecx, Operand(esp, (push_count + 1) * kPointerSize)); |
937 __ test(ecx, Operand(ecx)); | 937 __ test(ecx, Operand(ecx)); |
938 __ j(not_zero, ¬_empty_array); | 938 __ j(not_zero, ¬_empty_array); |
939 | 939 |
940 // Case above assumes there is only a single slot to drop in | 940 // The single argument passed is zero, so we jump to the code above used to |
941 // ret, but we have two. | 941 // handle the case of no arguments passed. To adapt the stack for that we move |
942 for (int i = push_count; i >= 0; i--) { | 942 // the return address and the pushed constructor (if pushed) one stack slot up |
| 943 // thereby removing the passed argument. Argc is also on the stack - at the |
| 944 // bottom - and it needs to be changed from 1 to 0 to have the call into the |
| 945 // runtime system work in case a GC is required. |
| 946 for (int i = push_count; i > 0; i--) { |
943 __ mov(eax, Operand(esp, i * kPointerSize)); | 947 __ mov(eax, Operand(esp, i * kPointerSize)); |
944 __ mov(Operand(esp, (i + 1) * kPointerSize), eax); | 948 __ mov(Operand(esp, (i + 1) * kPointerSize), eax); |
945 } | 949 } |
946 __ add(Operand(esp), Immediate(kPointerSize)); | 950 __ add(Operand(esp), Immediate(2 * kPointerSize)); // Drop two stack slots. |
| 951 __ push(Immediate(0)); // Treat this as a call with argc of zero. |
947 __ jmp(&empty_array); | 952 __ jmp(&empty_array); |
948 | 953 |
949 __ bind(¬_empty_array); | 954 __ bind(¬_empty_array); |
950 __ test(ecx, Immediate(kIntptrSignBit | kSmiTagMask)); | 955 __ test(ecx, Immediate(kIntptrSignBit | kSmiTagMask)); |
951 __ j(not_zero, &prepare_generic_code_call); | 956 __ j(not_zero, &prepare_generic_code_call); |
952 | 957 |
953 // Handle construction of an empty array of a certain size. Get the size from | 958 // Handle construction of an empty array of a certain size. Get the size from |
954 // the stack and bail out if size is to large to actually allocate an elements | 959 // the stack and bail out if size is to large to actually allocate an elements |
955 // array. | 960 // array. |
956 __ cmp(ecx, JSObject::kInitialMaxFastElementArray << kSmiTagSize); | 961 __ cmp(ecx, JSObject::kInitialMaxFastElementArray << kSmiTagSize); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 // Dont adapt arguments. | 1240 // Dont adapt arguments. |
1236 // ------------------------------------------- | 1241 // ------------------------------------------- |
1237 __ bind(&dont_adapt_arguments); | 1242 __ bind(&dont_adapt_arguments); |
1238 __ jmp(Operand(edx)); | 1243 __ jmp(Operand(edx)); |
1239 } | 1244 } |
1240 | 1245 |
1241 | 1246 |
1242 #undef __ | 1247 #undef __ |
1243 | 1248 |
1244 } } // namespace v8::internal | 1249 } } // namespace v8::internal |
OLD | NEW |