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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 const int kFunctionOffset = 4 * kPointerSize; | 1022 const int kFunctionOffset = 4 * kPointerSize; |
1023 | 1023 |
1024 __ EnterInternalFrame(); | 1024 __ EnterInternalFrame(); |
1025 | 1025 |
1026 __ ldr(r0, MemOperand(fp, kFunctionOffset)); // get the function | 1026 __ ldr(r0, MemOperand(fp, kFunctionOffset)); // get the function |
1027 __ push(r0); | 1027 __ push(r0); |
1028 __ ldr(r0, MemOperand(fp, kArgsOffset)); // get the args array | 1028 __ ldr(r0, MemOperand(fp, kArgsOffset)); // get the args array |
1029 __ push(r0); | 1029 __ push(r0); |
1030 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_JS); | 1030 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_JS); |
1031 | 1031 |
1032 Label no_preemption, retry_preemption; | 1032 // Check the stack for overflow. We are not trying need to catch |
1033 __ bind(&retry_preemption); | 1033 // interruptions (e.g. debug break and preemption) here, so the "real stack |
1034 ExternalReference stack_guard_limit_address = | 1034 // limit" is checked. |
1035 ExternalReference::address_of_stack_guard_limit(); | |
1036 __ mov(r2, Operand(stack_guard_limit_address)); | |
1037 __ ldr(r2, MemOperand(r2)); | |
1038 __ cmp(sp, r2); | |
1039 __ b(hi, &no_preemption); | |
1040 | |
1041 // We have encountered a preemption or stack overflow already before we push | |
1042 // the array contents. Save r0 which is the Smi-tagged length of the array. | |
1043 __ push(r0); | |
1044 | |
1045 // Runtime routines expect at least one argument, so give it a Smi. | |
1046 __ mov(r0, Operand(Smi::FromInt(0))); | |
1047 __ push(r0); | |
1048 __ CallRuntime(Runtime::kStackGuard, 1); | |
1049 | |
1050 // Since we returned, it wasn't a stack overflow. Restore r0 and try again. | |
1051 __ pop(r0); | |
1052 __ b(&retry_preemption); | |
1053 | |
1054 __ bind(&no_preemption); | |
1055 | |
1056 // Eagerly check for stack-overflow before starting to push the arguments. | |
1057 // r0: number of arguments. | |
1058 // r2: stack limit. | |
1059 Label okay; | 1035 Label okay; |
| 1036 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); |
| 1037 // Make r2 the space we have left. The stack might already be overflowed |
| 1038 // here which will cause r2 to become negative. |
1060 __ sub(r2, sp, r2); | 1039 __ sub(r2, sp, r2); |
1061 | 1040 // Check if the arguments will overflow the stack. |
1062 __ cmp(r2, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); | 1041 __ cmp(r2, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
1063 __ b(hi, &okay); | 1042 __ b(gt, &okay); // Signed comparison. |
1064 | 1043 |
1065 // Out of stack space. | 1044 // Out of stack space. |
1066 __ ldr(r1, MemOperand(fp, kFunctionOffset)); | 1045 __ ldr(r1, MemOperand(fp, kFunctionOffset)); |
1067 __ push(r1); | 1046 __ push(r1); |
1068 __ push(r0); | 1047 __ push(r0); |
1069 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_JS); | 1048 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_JS); |
| 1049 // End of stack check. |
1070 | 1050 |
1071 // Push current limit and index. | 1051 // Push current limit and index. |
1072 __ bind(&okay); | 1052 __ bind(&okay); |
1073 __ push(r0); // limit | 1053 __ push(r0); // limit |
1074 __ mov(r1, Operand(0)); // initial index | 1054 __ mov(r1, Operand(0)); // initial index |
1075 __ push(r1); | 1055 __ push(r1); |
1076 | 1056 |
1077 // Change context eagerly to get the right global object if necessary. | 1057 // Change context eagerly to get the right global object if necessary. |
1078 __ ldr(r0, MemOperand(fp, kFunctionOffset)); | 1058 __ ldr(r0, MemOperand(fp, kFunctionOffset)); |
1079 __ ldr(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); | 1059 __ ldr(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 // Dont adapt arguments. | 1262 // Dont adapt arguments. |
1283 // ------------------------------------------- | 1263 // ------------------------------------------- |
1284 __ bind(&dont_adapt_arguments); | 1264 __ bind(&dont_adapt_arguments); |
1285 __ Jump(r3); | 1265 __ Jump(r3); |
1286 } | 1266 } |
1287 | 1267 |
1288 | 1268 |
1289 #undef __ | 1269 #undef __ |
1290 | 1270 |
1291 } } // namespace v8::internal | 1271 } } // namespace v8::internal |
OLD | NEW |