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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 // stack. | 942 // stack. |
943 __ mov(edx, eax); | 943 __ mov(edx, eax); |
944 __ shl(edx, kPointerSizeLog2 - kSmiTagSize); | 944 __ shl(edx, kPointerSizeLog2 - kSmiTagSize); |
945 // Check if the arguments will overflow the stack. | 945 // Check if the arguments will overflow the stack. |
946 __ cmp(ecx, edx); | 946 __ cmp(ecx, edx); |
947 __ j(greater, &okay); // Signed comparison. | 947 __ j(greater, &okay); // Signed comparison. |
948 | 948 |
949 // Out of stack space. | 949 // Out of stack space. |
950 __ push(Operand(ebp, 4 * kPointerSize)); // push this | 950 __ push(Operand(ebp, 4 * kPointerSize)); // push this |
951 __ push(eax); | 951 __ push(eax); |
952 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 952 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); |
953 __ bind(&okay); | 953 __ bind(&okay); |
954 // End of stack check. | 954 // End of stack check. |
955 | 955 |
956 // Push current index and limit. | 956 // Push current index and limit. |
957 const int kLimitOffset = | 957 const int kLimitOffset = |
958 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | 958 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; |
959 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 959 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
960 __ push(eax); // limit | 960 __ push(eax); // limit |
961 __ push(Immediate(0)); // index | 961 __ push(Immediate(0)); // index |
962 | 962 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 __ IncrementCounter(counters->string_ctor_gc_required(), 1); | 1245 __ IncrementCounter(counters->string_ctor_gc_required(), 1); |
1246 { | 1246 { |
1247 FrameScope scope(masm, StackFrame::INTERNAL); | 1247 FrameScope scope(masm, StackFrame::INTERNAL); |
1248 __ push(ebx); | 1248 __ push(ebx); |
1249 __ CallRuntime(Runtime::kNewStringWrapper, 1); | 1249 __ CallRuntime(Runtime::kNewStringWrapper, 1); |
1250 } | 1250 } |
1251 __ ret(0); | 1251 __ ret(0); |
1252 } | 1252 } |
1253 | 1253 |
1254 | 1254 |
1255 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, | |
1256 Label* stack_overflow) { | |
1257 // ----------- S t a t e ------------- | |
1258 // -- eax : actual number of arguments | |
1259 // -- ebx : expected number of arguments | |
1260 // -- edi : function (passed through to callee) | |
1261 // ----------------------------------- | |
1262 // Check the stack for overflow. We are not trying to catch | |
1263 // interruptions (e.g. debug break and preemption) here, so the "real stack | |
1264 // limit" is checked. | |
1265 ExternalReference real_stack_limit = | |
1266 ExternalReference::address_of_real_stack_limit(masm->isolate()); | |
1267 __ mov(edx, Operand::StaticVariable(real_stack_limit)); | |
1268 // Make ecx the space we have left. The stack might already be overflowed | |
1269 // here which will cause ecx to become negative. | |
1270 __ mov(ecx, esp); | |
1271 __ sub(ecx, edx); | |
1272 // Make edx the space we need for the array when it is unrolled onto the | |
1273 // stack. | |
1274 __ mov(edx, ebx); | |
1275 __ shl(edx, kPointerSizeLog2); | |
1276 // Check if the arguments will overflow the stack. | |
1277 __ cmp(ecx, edx); | |
1278 __ j(less_equal, stack_overflow); // Signed comparison. | |
1279 } | |
1280 | |
1281 | |
1282 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1255 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
1283 __ push(ebp); | 1256 __ push(ebp); |
1284 __ mov(ebp, esp); | 1257 __ mov(ebp, esp); |
1285 | 1258 |
1286 // Store the arguments adaptor context sentinel. | 1259 // Store the arguments adaptor context sentinel. |
1287 __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1260 __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
1288 | 1261 |
1289 // Push the function on the stack. | 1262 // Push the function on the stack. |
1290 __ push(edi); | 1263 __ push(edi); |
1291 | 1264 |
(...skipping 24 matching lines...) Expand all Loading... |
1316 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1289 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
1317 // ----------- S t a t e ------------- | 1290 // ----------- S t a t e ------------- |
1318 // -- eax : actual number of arguments | 1291 // -- eax : actual number of arguments |
1319 // -- ebx : expected number of arguments | 1292 // -- ebx : expected number of arguments |
1320 // -- edi : function (passed through to callee) | 1293 // -- edi : function (passed through to callee) |
1321 // ----------------------------------- | 1294 // ----------------------------------- |
1322 | 1295 |
1323 Label invoke, dont_adapt_arguments; | 1296 Label invoke, dont_adapt_arguments; |
1324 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); | 1297 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); |
1325 | 1298 |
1326 Label stack_overflow; | |
1327 ArgumentsAdaptorStackCheck(masm, &stack_overflow); | |
1328 | |
1329 Label enough, too_few; | 1299 Label enough, too_few; |
1330 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 1300 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
1331 __ cmp(eax, ebx); | 1301 __ cmp(eax, ebx); |
1332 __ j(less, &too_few); | 1302 __ j(less, &too_few); |
1333 __ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); | 1303 __ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); |
1334 __ j(equal, &dont_adapt_arguments); | 1304 __ j(equal, &dont_adapt_arguments); |
1335 | 1305 |
1336 { // Enough parameters: Actual >= expected. | 1306 { // Enough parameters: Actual >= expected. |
1337 __ bind(&enough); | 1307 __ bind(&enough); |
1338 EnterArgumentsAdaptorFrame(masm); | 1308 EnterArgumentsAdaptorFrame(masm); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 | 1363 |
1394 // Leave frame and return. | 1364 // Leave frame and return. |
1395 LeaveArgumentsAdaptorFrame(masm); | 1365 LeaveArgumentsAdaptorFrame(masm); |
1396 __ ret(0); | 1366 __ ret(0); |
1397 | 1367 |
1398 // ------------------------------------------- | 1368 // ------------------------------------------- |
1399 // Dont adapt arguments. | 1369 // Dont adapt arguments. |
1400 // ------------------------------------------- | 1370 // ------------------------------------------- |
1401 __ bind(&dont_adapt_arguments); | 1371 __ bind(&dont_adapt_arguments); |
1402 __ jmp(edx); | 1372 __ jmp(edx); |
1403 | |
1404 __ bind(&stack_overflow); | |
1405 EnterArgumentsAdaptorFrame(masm); | |
1406 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION); | |
1407 __ int3(); | |
1408 } | 1373 } |
1409 | 1374 |
1410 | 1375 |
1411 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1376 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1412 // Lookup the function in the JavaScript frame. | 1377 // Lookup the function in the JavaScript frame. |
1413 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1378 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1414 { | 1379 { |
1415 FrameScope scope(masm, StackFrame::INTERNAL); | 1380 FrameScope scope(masm, StackFrame::INTERNAL); |
1416 // Pass function as argument. | 1381 // Pass function as argument. |
1417 __ push(eax); | 1382 __ push(eax); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 | 1426 |
1462 __ bind(&ok); | 1427 __ bind(&ok); |
1463 __ ret(0); | 1428 __ ret(0); |
1464 } | 1429 } |
1465 | 1430 |
1466 #undef __ | 1431 #undef __ |
1467 } | 1432 } |
1468 } // namespace v8::internal | 1433 } // namespace v8::internal |
1469 | 1434 |
1470 #endif // V8_TARGET_ARCH_IA32 | 1435 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |