Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/builtins-ia32.cc

Issue 2926: Fix stack check wraparound problem for ARM simulator. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 508 }
509 509
510 510
511 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 511 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
512 __ EnterInternalFrame(); 512 __ EnterInternalFrame();
513 513
514 __ push(Operand(ebp, 4 * kPointerSize)); // push this 514 __ push(Operand(ebp, 4 * kPointerSize)); // push this
515 __ push(Operand(ebp, 2 * kPointerSize)); // push arguments 515 __ push(Operand(ebp, 2 * kPointerSize)); // push arguments
516 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); 516 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION);
517 517
518 // We need to catch preemptions right here, otherwise an unlucky preemption
519 // could show up as a failed apply.
520 ExternalReference stack_guard_limit =
521 ExternalReference::address_of_stack_guard_limit();
522 Label retry_preemption;
523 Label no_preemption;
524 __ bind(&retry_preemption);
525 __ mov(edi, Operand::StaticVariable(stack_guard_limit));
526 __ cmp(esp, Operand(edi));
527 __ j(above, &no_preemption, taken);
Søren Thygesen Gjesse 2008/09/26 10:55:19 void Ia32CodeGenerator::CheckStack() uses above_eq
528
529 // Preemption!
530 // Because builtins always remove the receiver from the stack, we
531 // have to fake one to avoid underflowing the stack.
532 __ push(eax);
533 __ push(Immediate(Smi::FromInt(0)));
534
535 // Do call to runtime routine.
536 __ CallRuntime(Runtime::kStackGuard, 1);
537 __ pop(eax);
538 __ jmp(&retry_preemption);
539
540 __ bind(&no_preemption);
541
542 // Keep the stack limit in the edi register from here on.
518 // Eagerly check for stack-overflow before pushing all the arguments 543 // Eagerly check for stack-overflow before pushing all the arguments
519 // to the stack. 544 // to the stack.
520 Label okay; 545 Label okay;
521 __ lea(ecx, Operand(esp, -3 * kPointerSize)); // receiver, limit, index 546 // Make ecx the space we have left.
547 __ mov(ecx, Operand(esp));
548 __ sub(ecx, Operand(edi));
549 // Make edx the space we need for the array when it is unrolled onto the
550 // stack.
522 __ mov(edx, Operand(eax)); 551 __ mov(edx, Operand(eax));
523 __ shl(edx, kPointerSizeLog2 - kSmiTagSize); 552 __ shl(edx, kPointerSizeLog2 - kSmiTagSize);
524 __ sub(ecx, Operand(edx)); 553 __ cmp(ecx, Operand(edx));
525 ExternalReference stack_guard_limit_address =
526 ExternalReference::address_of_stack_guard_limit();
527 __ cmp(ecx, Operand::StaticVariable(stack_guard_limit_address));
528 __ j(greater, &okay, taken); 554 __ j(greater, &okay, taken);
529 555
530 // Too bad: Out of stack space. 556 // Too bad: Out of stack space.
531 __ push(Operand(ebp, 4 * kPointerSize)); // push this 557 __ push(Operand(ebp, 4 * kPointerSize)); // push this
532 __ push(eax); 558 __ push(eax);
533 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); 559 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION);
534 __ bind(&okay); 560 __ bind(&okay);
535 561
536 // Push current index and limit. 562 // Push current index and limit.
537 const int kLimitOffset = 563 const int kLimitOffset =
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // Register state for stub CallFunction (from CallFunctionStub in ic-ia32.cc). 902 // Register state for stub CallFunction (from CallFunctionStub in ic-ia32.cc).
877 // ----------- S t a t e ------------- 903 // ----------- S t a t e -------------
878 // No registers used on entry. 904 // No registers used on entry.
879 // ----------------------------------- 905 // -----------------------------------
880 Generate_DebugBreakCallHelper(masm, 0, false); 906 Generate_DebugBreakCallHelper(masm, 0, false);
881 } 907 }
882 908
883 #undef __ 909 #undef __
884 910
885 } } // namespace v8::internal 911 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698