| 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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 | 1830 |
| 1831 // ------------------------------------------- | 1831 // ------------------------------------------- |
| 1832 // Dont adapt arguments. | 1832 // Dont adapt arguments. |
| 1833 // ------------------------------------------- | 1833 // ------------------------------------------- |
| 1834 __ bind(&dont_adapt_arguments); | 1834 __ bind(&dont_adapt_arguments); |
| 1835 __ jmp(rdx); | 1835 __ jmp(rdx); |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 | 1838 |
| 1839 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1839 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
| 1840 // Get the loop depth of the stack guard check. This is recorded in | |
| 1841 // a test(rax, depth) instruction right after the call. | |
| 1842 Label stack_check; | |
| 1843 __ movq(rbx, Operand(rsp, 0)); // return address | |
| 1844 __ movzxbq(rbx, Operand(rbx, 1)); // depth | |
| 1845 | |
| 1846 // Get the loop nesting level at which we allow OSR from the | |
| 1847 // unoptimized code and check if we want to do OSR yet. If not we | |
| 1848 // should perform a stack guard check so we can get interrupts while | |
| 1849 // waiting for on-stack replacement. | |
| 1850 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1840 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1851 __ movq(rcx, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); | |
| 1852 __ movq(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); | |
| 1853 __ cmpb(rbx, FieldOperand(rcx, Code::kAllowOSRAtLoopNestingLevelOffset)); | |
| 1854 __ j(greater, &stack_check); | |
| 1855 | 1841 |
| 1856 // Pass the function to optimize as the argument to the on-stack | 1842 // Pass the function to optimize as the argument to the on-stack |
| 1857 // replacement runtime function. | 1843 // replacement runtime function. |
| 1858 { | 1844 { |
| 1859 FrameScope scope(masm, StackFrame::INTERNAL); | 1845 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1860 __ push(rax); | 1846 __ push(rax); |
| 1861 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | 1847 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); |
| 1862 } | 1848 } |
| 1863 | 1849 |
| 1864 // If the result was -1 it means that we couldn't optimize the | 1850 // If the result was -1 it means that we couldn't optimize the |
| 1865 // function. Just return and continue in the unoptimized version. | 1851 // function. Just return and continue in the unoptimized version. |
| 1866 Label skip; | 1852 Label skip; |
| 1867 __ SmiCompare(rax, Smi::FromInt(-1)); | 1853 __ SmiCompare(rax, Smi::FromInt(-1)); |
| 1868 __ j(not_equal, &skip, Label::kNear); | 1854 __ j(not_equal, &skip, Label::kNear); |
| 1869 __ ret(0); | 1855 __ ret(0); |
| 1870 | 1856 |
| 1871 // If we decide not to perform on-stack replacement we perform a | |
| 1872 // stack guard check to enable interrupts. | |
| 1873 __ bind(&stack_check); | |
| 1874 Label ok; | |
| 1875 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | |
| 1876 __ j(above_equal, &ok, Label::kNear); | |
| 1877 | |
| 1878 StackCheckStub stub; | |
| 1879 __ TailCallStub(&stub); | |
| 1880 if (FLAG_debug_code) { | |
| 1881 __ Abort("Unreachable code: returned from tail call."); | |
| 1882 } | |
| 1883 __ bind(&ok); | |
| 1884 __ ret(0); | |
| 1885 | |
| 1886 __ bind(&skip); | 1857 __ bind(&skip); |
| 1887 // Untag the AST id and push it on the stack. | 1858 // Untag the AST id and push it on the stack. |
| 1888 __ SmiToInteger32(rax, rax); | 1859 __ SmiToInteger32(rax, rax); |
| 1889 __ push(rax); | 1860 __ push(rax); |
| 1890 | 1861 |
| 1891 // Generate the code for doing the frame-to-frame translation using | 1862 // Generate the code for doing the frame-to-frame translation using |
| 1892 // the deoptimizer infrastructure. | 1863 // the deoptimizer infrastructure. |
| 1893 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1864 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1894 generator.Generate(); | 1865 generator.Generate(); |
| 1895 } | 1866 } |
| 1896 | 1867 |
| 1897 | 1868 |
| 1898 #undef __ | 1869 #undef __ |
| 1899 | 1870 |
| 1900 } } // namespace v8::internal | 1871 } } // namespace v8::internal |
| 1901 | 1872 |
| 1902 #endif // V8_TARGET_ARCH_X64 | 1873 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |