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 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 1722 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
1723 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, | 1723 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, |
1724 in_loop); | 1724 in_loop); |
1725 __ Call(ic, mode); | 1725 __ Call(ic, mode); |
1726 // Restore context register. | 1726 // Restore context register. |
1727 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1727 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
1728 Apply(context_, rax); | 1728 Apply(context_, rax); |
1729 } | 1729 } |
1730 | 1730 |
1731 | 1731 |
| 1732 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| 1733 Expression* key, |
| 1734 RelocInfo::Mode mode) { |
| 1735 // Code common for calls using the IC. |
| 1736 ZoneList<Expression*>* args = expr->arguments(); |
| 1737 int arg_count = args->length(); |
| 1738 for (int i = 0; i < arg_count; i++) { |
| 1739 VisitForValue(args->at(i), kStack); |
| 1740 } |
| 1741 VisitForValue(key, kAccumulator); |
| 1742 __ movq(rcx, rax); |
| 1743 // Record source position for debugger. |
| 1744 SetSourcePosition(expr->position()); |
| 1745 // Call the IC initialization code. |
| 1746 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 1747 Handle<Code> ic = CodeGenerator::ComputeKeyedCallInitialize(arg_count, |
| 1748 in_loop); |
| 1749 __ Call(ic, mode); |
| 1750 // Restore context register. |
| 1751 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1752 Apply(context_, rax); |
| 1753 } |
| 1754 |
| 1755 |
1732 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 1756 void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
1733 // Code common for calls using the call stub. | 1757 // Code common for calls using the call stub. |
1734 ZoneList<Expression*>* args = expr->arguments(); | 1758 ZoneList<Expression*>* args = expr->arguments(); |
1735 int arg_count = args->length(); | 1759 int arg_count = args->length(); |
1736 for (int i = 0; i < arg_count; i++) { | 1760 for (int i = 0; i < arg_count; i++) { |
1737 VisitForValue(args->at(i), kStack); | 1761 VisitForValue(args->at(i), kStack); |
1738 } | 1762 } |
1739 // Record source position for debugger. | 1763 // Record source position for debugger. |
1740 SetSourcePosition(expr->position()); | 1764 SetSourcePosition(expr->position()); |
1741 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 1765 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 EmitCallWithStub(expr); | 1837 EmitCallWithStub(expr); |
1814 } else if (fun->AsProperty() != NULL) { | 1838 } else if (fun->AsProperty() != NULL) { |
1815 // Call to an object property. | 1839 // Call to an object property. |
1816 Property* prop = fun->AsProperty(); | 1840 Property* prop = fun->AsProperty(); |
1817 Literal* key = prop->key()->AsLiteral(); | 1841 Literal* key = prop->key()->AsLiteral(); |
1818 if (key != NULL && key->handle()->IsSymbol()) { | 1842 if (key != NULL && key->handle()->IsSymbol()) { |
1819 // Call to a named property, use call IC. | 1843 // Call to a named property, use call IC. |
1820 VisitForValue(prop->obj(), kStack); | 1844 VisitForValue(prop->obj(), kStack); |
1821 EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); | 1845 EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); |
1822 } else { | 1846 } else { |
1823 // Call to a keyed property, use keyed load IC followed by function | 1847 // Call to a keyed property. |
1824 // call. | 1848 // For a synthetic property use keyed load IC followed by function call, |
| 1849 // for a regular property use KeyedCallIC. |
1825 VisitForValue(prop->obj(), kStack); | 1850 VisitForValue(prop->obj(), kStack); |
1826 VisitForValue(prop->key(), kAccumulator); | |
1827 __ movq(rdx, Operand(rsp, 0)); | |
1828 // Record source code position for IC call. | |
1829 SetSourcePosition(prop->position()); | |
1830 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | |
1831 __ call(ic, RelocInfo::CODE_TARGET); | |
1832 // By emitting a nop we make sure that we do not have a "test rax,..." | |
1833 // instruction after the call it is treated specially by the LoadIC code. | |
1834 __ nop(); | |
1835 // Pop receiver. | |
1836 __ pop(rbx); | |
1837 // Push result (function). | |
1838 __ push(rax); | |
1839 // Push receiver object on stack. | |
1840 if (prop->is_synthetic()) { | 1851 if (prop->is_synthetic()) { |
| 1852 VisitForValue(prop->key(), kAccumulator); |
| 1853 __ movq(rdx, Operand(rsp, 0)); |
| 1854 // Record source code position for IC call. |
| 1855 SetSourcePosition(prop->position()); |
| 1856 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 1857 __ call(ic, RelocInfo::CODE_TARGET); |
| 1858 // By emitting a nop we make sure that we do not have a "test rax,..." |
| 1859 // instruction after the call as it is treated specially |
| 1860 // by the LoadIC code. |
| 1861 __ nop(); |
| 1862 // Pop receiver. |
| 1863 __ pop(rbx); |
| 1864 // Push result (function). |
| 1865 __ push(rax); |
| 1866 // Push receiver object on stack. |
1841 __ movq(rcx, CodeGenerator::GlobalObject()); | 1867 __ movq(rcx, CodeGenerator::GlobalObject()); |
1842 __ push(FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); | 1868 __ push(FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); |
| 1869 EmitCallWithStub(expr); |
1843 } else { | 1870 } else { |
1844 __ push(rbx); | 1871 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); |
1845 } | 1872 } |
1846 EmitCallWithStub(expr); | |
1847 } | 1873 } |
1848 } else { | 1874 } else { |
1849 // Call to some other expression. If the expression is an anonymous | 1875 // Call to some other expression. If the expression is an anonymous |
1850 // function literal not called in a loop, mark it as one that should | 1876 // function literal not called in a loop, mark it as one that should |
1851 // also use the fast code generator. | 1877 // also use the fast code generator. |
1852 FunctionLiteral* lit = fun->AsFunctionLiteral(); | 1878 FunctionLiteral* lit = fun->AsFunctionLiteral(); |
1853 if (lit != NULL && | 1879 if (lit != NULL && |
1854 lit->name()->Equals(Heap::empty_string()) && | 1880 lit->name()->Equals(Heap::empty_string()) && |
1855 loop_depth() == 0) { | 1881 loop_depth() == 0) { |
1856 lit->set_try_full_codegen(true); | 1882 lit->set_try_full_codegen(true); |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 __ ret(0); | 3240 __ ret(0); |
3215 } | 3241 } |
3216 | 3242 |
3217 | 3243 |
3218 #undef __ | 3244 #undef __ |
3219 | 3245 |
3220 | 3246 |
3221 } } // namespace v8::internal | 3247 } } // namespace v8::internal |
3222 | 3248 |
3223 #endif // V8_TARGET_ARCH_X64 | 3249 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |