| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 616 |
| 617 MaybeObject* MacroAssembler::TryJumpToExternalReference( | 617 MaybeObject* MacroAssembler::TryJumpToExternalReference( |
| 618 const ExternalReference& ext, int result_size) { | 618 const ExternalReference& ext, int result_size) { |
| 619 // Set the entry point and jump to the C entry runtime stub. | 619 // Set the entry point and jump to the C entry runtime stub. |
| 620 movq(rbx, ext); | 620 movq(rbx, ext); |
| 621 CEntryStub ces(result_size); | 621 CEntryStub ces(result_size); |
| 622 return TryTailCallStub(&ces); | 622 return TryTailCallStub(&ces); |
| 623 } | 623 } |
| 624 | 624 |
| 625 | 625 |
| 626 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) { | 626 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
| 627 InvokeFlag flag, |
| 628 PostCallGenerator* post_call_generator) { |
| 627 // Calls are not allowed in some stubs. | 629 // Calls are not allowed in some stubs. |
| 628 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); | 630 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); |
| 629 | 631 |
| 630 // Rely on the assertion to check that the number of provided | 632 // Rely on the assertion to check that the number of provided |
| 631 // arguments match the expected number of arguments. Fake a | 633 // arguments match the expected number of arguments. Fake a |
| 632 // parameter count to avoid emitting code to do the check. | 634 // parameter count to avoid emitting code to do the check. |
| 633 ParameterCount expected(0); | 635 ParameterCount expected(0); |
| 634 GetBuiltinEntry(rdx, id); | 636 GetBuiltinEntry(rdx, id); |
| 635 InvokeCode(rdx, expected, expected, flag); | 637 InvokeCode(rdx, expected, expected, flag, post_call_generator); |
| 636 } | 638 } |
| 637 | 639 |
| 638 | 640 |
| 639 void MacroAssembler::GetBuiltinFunction(Register target, | 641 void MacroAssembler::GetBuiltinFunction(Register target, |
| 640 Builtins::JavaScript id) { | 642 Builtins::JavaScript id) { |
| 641 // Load the builtins object into target register. | 643 // Load the builtins object into target register. |
| 642 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 644 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 643 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | 645 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); |
| 644 movq(target, FieldOperand(target, | 646 movq(target, FieldOperand(target, |
| 645 JSBuiltinsObject::OffsetOfFunctionWithId(id))); | 647 JSBuiltinsObject::OffsetOfFunctionWithId(id))); |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 movq(rbx, ExternalReference(Runtime::kDebugBreak)); | 1830 movq(rbx, ExternalReference(Runtime::kDebugBreak)); |
| 1829 CEntryStub ces(1); | 1831 CEntryStub ces(1); |
| 1830 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); | 1832 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); |
| 1831 } | 1833 } |
| 1832 #endif // ENABLE_DEBUGGER_SUPPORT | 1834 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1833 | 1835 |
| 1834 | 1836 |
| 1835 void MacroAssembler::InvokeCode(Register code, | 1837 void MacroAssembler::InvokeCode(Register code, |
| 1836 const ParameterCount& expected, | 1838 const ParameterCount& expected, |
| 1837 const ParameterCount& actual, | 1839 const ParameterCount& actual, |
| 1838 InvokeFlag flag) { | 1840 InvokeFlag flag, |
| 1841 PostCallGenerator* post_call_generator) { |
| 1839 NearLabel done; | 1842 NearLabel done; |
| 1840 InvokePrologue(expected, actual, Handle<Code>::null(), code, &done, flag); | 1843 InvokePrologue(expected, |
| 1844 actual, |
| 1845 Handle<Code>::null(), |
| 1846 code, |
| 1847 &done, |
| 1848 flag, |
| 1849 post_call_generator); |
| 1841 if (flag == CALL_FUNCTION) { | 1850 if (flag == CALL_FUNCTION) { |
| 1842 call(code); | 1851 call(code); |
| 1852 if (post_call_generator != NULL) post_call_generator->Generate(); |
| 1843 } else { | 1853 } else { |
| 1844 ASSERT(flag == JUMP_FUNCTION); | 1854 ASSERT(flag == JUMP_FUNCTION); |
| 1845 jmp(code); | 1855 jmp(code); |
| 1846 } | 1856 } |
| 1847 bind(&done); | 1857 bind(&done); |
| 1848 } | 1858 } |
| 1849 | 1859 |
| 1850 | 1860 |
| 1851 void MacroAssembler::InvokeCode(Handle<Code> code, | 1861 void MacroAssembler::InvokeCode(Handle<Code> code, |
| 1852 const ParameterCount& expected, | 1862 const ParameterCount& expected, |
| 1853 const ParameterCount& actual, | 1863 const ParameterCount& actual, |
| 1854 RelocInfo::Mode rmode, | 1864 RelocInfo::Mode rmode, |
| 1855 InvokeFlag flag) { | 1865 InvokeFlag flag, |
| 1866 PostCallGenerator* post_call_generator) { |
| 1856 NearLabel done; | 1867 NearLabel done; |
| 1857 Register dummy = rax; | 1868 Register dummy = rax; |
| 1858 InvokePrologue(expected, actual, code, dummy, &done, flag); | 1869 InvokePrologue(expected, |
| 1870 actual, |
| 1871 code, |
| 1872 dummy, |
| 1873 &done, |
| 1874 flag, |
| 1875 post_call_generator); |
| 1859 if (flag == CALL_FUNCTION) { | 1876 if (flag == CALL_FUNCTION) { |
| 1860 Call(code, rmode); | 1877 Call(code, rmode); |
| 1878 if (post_call_generator != NULL) post_call_generator->Generate(); |
| 1861 } else { | 1879 } else { |
| 1862 ASSERT(flag == JUMP_FUNCTION); | 1880 ASSERT(flag == JUMP_FUNCTION); |
| 1863 Jump(code, rmode); | 1881 Jump(code, rmode); |
| 1864 } | 1882 } |
| 1865 bind(&done); | 1883 bind(&done); |
| 1866 } | 1884 } |
| 1867 | 1885 |
| 1868 | 1886 |
| 1869 void MacroAssembler::InvokeFunction(Register function, | 1887 void MacroAssembler::InvokeFunction(Register function, |
| 1870 const ParameterCount& actual, | 1888 const ParameterCount& actual, |
| 1871 InvokeFlag flag) { | 1889 InvokeFlag flag, |
| 1890 PostCallGenerator* post_call_generator) { |
| 1872 ASSERT(function.is(rdi)); | 1891 ASSERT(function.is(rdi)); |
| 1873 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 1892 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
| 1874 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); | 1893 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); |
| 1875 movsxlq(rbx, | 1894 movsxlq(rbx, |
| 1876 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); | 1895 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1877 // Advances rdx to the end of the Code object header, to the start of | 1896 // Advances rdx to the end of the Code object header, to the start of |
| 1878 // the executable code. | 1897 // the executable code. |
| 1879 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 1898 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
| 1880 | 1899 |
| 1881 ParameterCount expected(rbx); | 1900 ParameterCount expected(rbx); |
| 1882 InvokeCode(rdx, expected, actual, flag); | 1901 InvokeCode(rdx, expected, actual, flag, post_call_generator); |
| 1883 } | 1902 } |
| 1884 | 1903 |
| 1885 | 1904 |
| 1886 void MacroAssembler::InvokeFunction(JSFunction* function, | 1905 void MacroAssembler::InvokeFunction(JSFunction* function, |
| 1887 const ParameterCount& actual, | 1906 const ParameterCount& actual, |
| 1888 InvokeFlag flag) { | 1907 InvokeFlag flag, |
| 1908 PostCallGenerator* post_call_generator) { |
| 1889 ASSERT(function->is_compiled()); | 1909 ASSERT(function->is_compiled()); |
| 1890 // Get the function and setup the context. | 1910 // Get the function and setup the context. |
| 1891 Move(rdi, Handle<JSFunction>(function)); | 1911 Move(rdi, Handle<JSFunction>(function)); |
| 1892 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 1912 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 1893 | 1913 |
| 1894 if (V8::UseCrankshaft()) { | 1914 if (V8::UseCrankshaft()) { |
| 1895 // Since Crankshaft can recompile a function, we need to load | 1915 // Since Crankshaft can recompile a function, we need to load |
| 1896 // the Code object every time we call the function. | 1916 // the Code object every time we call the function. |
| 1897 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 1917 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
| 1898 ParameterCount expected(function->shared()->formal_parameter_count()); | 1918 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 1899 InvokeCode(rdx, expected, actual, flag); | 1919 InvokeCode(rdx, expected, actual, flag, post_call_generator); |
| 1900 } else { | 1920 } else { |
| 1901 // Invoke the cached code. | 1921 // Invoke the cached code. |
| 1902 Handle<Code> code(function->code()); | 1922 Handle<Code> code(function->code()); |
| 1903 ParameterCount expected(function->shared()->formal_parameter_count()); | 1923 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 1904 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, flag); | 1924 InvokeCode(code, |
| 1925 expected, |
| 1926 actual, |
| 1927 RelocInfo::CODE_TARGET, |
| 1928 flag, |
| 1929 post_call_generator); |
| 1905 } | 1930 } |
| 1906 } | 1931 } |
| 1907 | 1932 |
| 1908 | 1933 |
| 1909 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 1934 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
| 1910 push(rbp); | 1935 push(rbp); |
| 1911 movq(rbp, rsp); | 1936 movq(rbp, rsp); |
| 1912 push(rsi); // Context. | 1937 push(rsi); // Context. |
| 1913 Push(Smi::FromInt(type)); | 1938 Push(Smi::FromInt(type)); |
| 1914 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); | 1939 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 CPU::FlushICache(address_, size_); | 2622 CPU::FlushICache(address_, size_); |
| 2598 | 2623 |
| 2599 // Check that the code was patched as expected. | 2624 // Check that the code was patched as expected. |
| 2600 ASSERT(masm_.pc_ == address_ + size_); | 2625 ASSERT(masm_.pc_ == address_ + size_); |
| 2601 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2626 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2602 } | 2627 } |
| 2603 | 2628 |
| 2604 } } // namespace v8::internal | 2629 } } // namespace v8::internal |
| 2605 | 2630 |
| 2606 #endif // V8_TARGET_ARCH_X64 | 2631 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |