| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_X64) | 30 #if defined(V8_TARGET_ARCH_X64) |
| 31 | 31 |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
| 34 #include "compiler.h" | 34 #include "compiler.h" |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
| 37 #include "parser.h" | 37 #include "parser.h" |
| 38 #include "scopes.h" | 38 #include "scopes.h" |
| 39 #include "stub-cache.h" |
| 39 | 40 |
| 40 namespace v8 { | 41 namespace v8 { |
| 41 namespace internal { | 42 namespace internal { |
| 42 | 43 |
| 43 #define __ ACCESS_MASM(masm_) | 44 #define __ ACCESS_MASM(masm_) |
| 44 | 45 |
| 45 // Generate code for a JS function. On entry to the function the receiver | 46 // Generate code for a JS function. On entry to the function the receiver |
| 46 // and arguments have been pushed on the stack left to right, with the | 47 // and arguments have been pushed on the stack left to right, with the |
| 47 // return address on top of them. The actual argument count matches the | 48 // return address on top of them. The actual argument count matches the |
| 48 // formal parameter count expected by the function. | 49 // formal parameter count expected by the function. |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 1721 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 1721 for (int i = 0; i < arg_count; i++) { | 1722 for (int i = 0; i < arg_count; i++) { |
| 1722 VisitForStackValue(args->at(i)); | 1723 VisitForStackValue(args->at(i)); |
| 1723 } | 1724 } |
| 1724 __ Move(rcx, name); | 1725 __ Move(rcx, name); |
| 1725 } | 1726 } |
| 1726 // Record source position for debugger. | 1727 // Record source position for debugger. |
| 1727 SetSourcePosition(expr->position(), FORCED_POSITION); | 1728 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 1728 // Call the IC initialization code. | 1729 // Call the IC initialization code. |
| 1729 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 1730 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 1730 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, | 1731 Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop); |
| 1731 in_loop); | |
| 1732 EmitCallIC(ic, mode); | 1732 EmitCallIC(ic, mode); |
| 1733 // Restore context register. | 1733 // Restore context register. |
| 1734 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1734 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1735 context()->Plug(rax); | 1735 context()->Plug(rax); |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 | 1738 |
| 1739 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, | 1739 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| 1740 Expression* key, | 1740 Expression* key, |
| 1741 RelocInfo::Mode mode) { | 1741 RelocInfo::Mode mode) { |
| 1742 // Code common for calls using the IC. | 1742 // Code common for calls using the IC. |
| 1743 ZoneList<Expression*>* args = expr->arguments(); | 1743 ZoneList<Expression*>* args = expr->arguments(); |
| 1744 int arg_count = args->length(); | 1744 int arg_count = args->length(); |
| 1745 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 1745 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 1746 for (int i = 0; i < arg_count; i++) { | 1746 for (int i = 0; i < arg_count; i++) { |
| 1747 VisitForStackValue(args->at(i)); | 1747 VisitForStackValue(args->at(i)); |
| 1748 } | 1748 } |
| 1749 VisitForAccumulatorValue(key); | 1749 VisitForAccumulatorValue(key); |
| 1750 __ movq(rcx, rax); | 1750 __ movq(rcx, rax); |
| 1751 } | 1751 } |
| 1752 // Record source position for debugger. | 1752 // Record source position for debugger. |
| 1753 SetSourcePosition(expr->position(), FORCED_POSITION); | 1753 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 1754 // Call the IC initialization code. | 1754 // Call the IC initialization code. |
| 1755 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 1755 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 1756 Handle<Code> ic = CodeGenerator::ComputeKeyedCallInitialize(arg_count, | 1756 Handle<Code> ic = StubCache::ComputeKeyedCallInitialize(arg_count, in_loop); |
| 1757 in_loop); | |
| 1758 EmitCallIC(ic, mode); | 1757 EmitCallIC(ic, mode); |
| 1759 // Restore context register. | 1758 // Restore context register. |
| 1760 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1759 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1761 context()->Plug(rax); | 1760 context()->Plug(rax); |
| 1762 } | 1761 } |
| 1763 | 1762 |
| 1764 | 1763 |
| 1765 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 1764 void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
| 1766 // Code common for calls using the call stub. | 1765 // Code common for calls using the call stub. |
| 1767 ZoneList<Expression*>* args = expr->arguments(); | 1766 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 // Push the arguments ("left-to-right"). | 2807 // Push the arguments ("left-to-right"). |
| 2809 int arg_count = args->length(); | 2808 int arg_count = args->length(); |
| 2810 for (int i = 0; i < arg_count; i++) { | 2809 for (int i = 0; i < arg_count; i++) { |
| 2811 VisitForStackValue(args->at(i)); | 2810 VisitForStackValue(args->at(i)); |
| 2812 } | 2811 } |
| 2813 | 2812 |
| 2814 if (expr->is_jsruntime()) { | 2813 if (expr->is_jsruntime()) { |
| 2815 // Call the JS runtime function using a call IC. | 2814 // Call the JS runtime function using a call IC. |
| 2816 __ Move(rcx, expr->name()); | 2815 __ Move(rcx, expr->name()); |
| 2817 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2816 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 2818 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, in_loop); | 2817 Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop); |
| 2819 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 2818 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 2820 // Restore context register. | 2819 // Restore context register. |
| 2821 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2820 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2822 } else { | 2821 } else { |
| 2823 __ CallRuntime(expr->function(), arg_count); | 2822 __ CallRuntime(expr->function(), arg_count); |
| 2824 } | 2823 } |
| 2825 context()->Plug(rax); | 2824 context()->Plug(rax); |
| 2826 } | 2825 } |
| 2827 | 2826 |
| 2828 | 2827 |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3453 __ ret(0); | 3452 __ ret(0); |
| 3454 } | 3453 } |
| 3455 | 3454 |
| 3456 | 3455 |
| 3457 #undef __ | 3456 #undef __ |
| 3458 | 3457 |
| 3459 | 3458 |
| 3460 } } // namespace v8::internal | 3459 } } // namespace v8::internal |
| 3461 | 3460 |
| 3462 #endif // V8_TARGET_ARCH_X64 | 3461 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |