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

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

Issue 13811014: Fix OSR for nested loops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 8 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 | « src/full-codegen.cc ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 1803
1804 // ------------------------------------------- 1804 // -------------------------------------------
1805 // Dont adapt arguments. 1805 // Dont adapt arguments.
1806 // ------------------------------------------- 1806 // -------------------------------------------
1807 __ bind(&dont_adapt_arguments); 1807 __ bind(&dont_adapt_arguments);
1808 __ jmp(edx); 1808 __ jmp(edx);
1809 } 1809 }
1810 1810
1811 1811
1812 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 1812 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1813 // Get the loop depth of the stack guard check. This is recorded in
1814 // a test(eax, depth) instruction right after the call.
1815 Label stack_check;
1816 __ mov(ebx, Operand(esp, 0)); // return address
1817 if (FLAG_debug_code) {
1818 __ cmpb(Operand(ebx, 0), Assembler::kTestAlByte);
1819 __ Assert(equal, "test eax instruction not found after loop stack check");
1820 }
1821 __ movzx_b(ebx, Operand(ebx, 1)); // depth
1822
1823 // Get the loop nesting level at which we allow OSR from the
1824 // unoptimized code and check if we want to do OSR yet. If not we
1825 // should perform a stack guard check so we can get interrupts while
1826 // waiting for on-stack replacement.
1827 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1813 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1828 __ mov(ecx, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset));
1829 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kCodeOffset));
1830 __ cmpb(ebx, FieldOperand(ecx, Code::kAllowOSRAtLoopNestingLevelOffset));
1831 __ j(greater, &stack_check);
1832 1814
1833 // Pass the function to optimize as the argument to the on-stack 1815 // Pass the function to optimize as the argument to the on-stack
1834 // replacement runtime function. 1816 // replacement runtime function.
1835 { 1817 {
1836 FrameScope scope(masm, StackFrame::INTERNAL); 1818 FrameScope scope(masm, StackFrame::INTERNAL);
1837 __ push(eax); 1819 __ push(eax);
1838 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); 1820 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1);
1839 } 1821 }
1840 1822
1841 // If the result was -1 it means that we couldn't optimize the 1823 // If the result was -1 it means that we couldn't optimize the
1842 // function. Just return and continue in the unoptimized version. 1824 // function. Just return and continue in the unoptimized version.
1843 Label skip; 1825 Label skip;
1844 __ cmp(eax, Immediate(Smi::FromInt(-1))); 1826 __ cmp(eax, Immediate(Smi::FromInt(-1)));
1845 __ j(not_equal, &skip, Label::kNear); 1827 __ j(not_equal, &skip, Label::kNear);
1846 __ ret(0); 1828 __ ret(0);
1847 1829
1848 // Insert a stack guard check so that if we decide not to perform
1849 // on-stack replacement right away, the function calling this stub can
1850 // still be interrupted.
1851 __ bind(&stack_check);
1852 Label ok;
1853 ExternalReference stack_limit =
1854 ExternalReference::address_of_stack_limit(masm->isolate());
1855 __ cmp(esp, Operand::StaticVariable(stack_limit));
1856 __ j(above_equal, &ok, Label::kNear);
1857 StackCheckStub stub;
1858 __ TailCallStub(&stub);
1859 if (FLAG_debug_code) {
1860 __ Abort("Unreachable code: returned from tail call.");
1861 }
1862 __ bind(&ok);
1863 __ ret(0);
1864
1865 __ bind(&skip); 1830 __ bind(&skip);
1866 // Untag the AST id and push it on the stack. 1831 // Untag the AST id and push it on the stack.
1867 __ SmiUntag(eax); 1832 __ SmiUntag(eax);
1868 __ push(eax); 1833 __ push(eax);
1869 1834
1870 // Generate the code for doing the frame-to-frame translation using 1835 // Generate the code for doing the frame-to-frame translation using
1871 // the deoptimizer infrastructure. 1836 // the deoptimizer infrastructure.
1872 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1837 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1873 generator.Generate(); 1838 generator.Generate();
1874 } 1839 }
1875 1840
1876 1841
1877 #undef __ 1842 #undef __
1878 } 1843 }
1879 } // namespace v8::internal 1844 } // namespace v8::internal
1880 1845
1881 #endif // V8_TARGET_ARCH_IA32 1846 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698