| 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_X64) | 30 #if defined(V8_TARGET_ARCH_X64) |
| 31 | 31 |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "code-stubs-x64.h" | 33 #include "code-stubs.h" |
| 34 #include "codegen-inl.h" | 34 #include "codegen-inl.h" |
| 35 #include "compiler.h" | 35 #include "compiler.h" |
| 36 #include "debug.h" | 36 #include "debug.h" |
| 37 #include "ic-inl.h" | 37 #include "ic-inl.h" |
| 38 #include "parser.h" | 38 #include "parser.h" |
| 39 #include "regexp-macro-assembler.h" | 39 #include "regexp-macro-assembler.h" |
| 40 #include "register-allocator-inl.h" | 40 #include "register-allocator-inl.h" |
| 41 #include "scopes.h" | 41 #include "scopes.h" |
| 42 #include "virtual-frame-inl.h" | 42 #include "virtual-frame-inl.h" |
| 43 | 43 |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 | 1017 |
| 1018 TypeInfo result_type = CalculateTypeInfo(operands_type, op, right, left); | 1018 TypeInfo result_type = CalculateTypeInfo(operands_type, op, right, left); |
| 1019 | 1019 |
| 1020 Result answer; | 1020 Result answer; |
| 1021 if (left_is_non_smi_constant || right_is_non_smi_constant) { | 1021 if (left_is_non_smi_constant || right_is_non_smi_constant) { |
| 1022 // Go straight to the slow case, with no smi code. | 1022 // Go straight to the slow case, with no smi code. |
| 1023 GenericBinaryOpStub stub(op, | 1023 GenericBinaryOpStub stub(op, |
| 1024 overwrite_mode, | 1024 overwrite_mode, |
| 1025 NO_SMI_CODE_IN_STUB, | 1025 NO_SMI_CODE_IN_STUB, |
| 1026 operands_type); | 1026 operands_type); |
| 1027 answer = stub.GenerateCall(masm_, frame_, &left, &right); | 1027 answer = GenerateGenericBinaryOpStubCall(&stub, &left, &right); |
| 1028 } else if (right_is_smi_constant) { | 1028 } else if (right_is_smi_constant) { |
| 1029 answer = ConstantSmiBinaryOperation(expr, &left, right.handle(), | 1029 answer = ConstantSmiBinaryOperation(expr, &left, right.handle(), |
| 1030 false, overwrite_mode); | 1030 false, overwrite_mode); |
| 1031 } else if (left_is_smi_constant) { | 1031 } else if (left_is_smi_constant) { |
| 1032 answer = ConstantSmiBinaryOperation(expr, &right, left.handle(), | 1032 answer = ConstantSmiBinaryOperation(expr, &right, left.handle(), |
| 1033 true, overwrite_mode); | 1033 true, overwrite_mode); |
| 1034 } else { | 1034 } else { |
| 1035 // Set the flags based on the operation, type and loop nesting level. | 1035 // Set the flags based on the operation, type and loop nesting level. |
| 1036 // Bit operations always assume they likely operate on Smis. Still only | 1036 // Bit operations always assume they likely operate on Smis. Still only |
| 1037 // generate the inline Smi check code if this operation is part of a loop. | 1037 // generate the inline Smi check code if this operation is part of a loop. |
| 1038 // For all other operations only inline the Smi check code for likely smis | 1038 // For all other operations only inline the Smi check code for likely smis |
| 1039 // if the operation is part of a loop. | 1039 // if the operation is part of a loop. |
| 1040 if (loop_nesting() > 0 && | 1040 if (loop_nesting() > 0 && |
| 1041 (Token::IsBitOp(op) || | 1041 (Token::IsBitOp(op) || |
| 1042 operands_type.IsInteger32() || | 1042 operands_type.IsInteger32() || |
| 1043 expr->type()->IsLikelySmi())) { | 1043 expr->type()->IsLikelySmi())) { |
| 1044 answer = LikelySmiBinaryOperation(expr, &left, &right, overwrite_mode); | 1044 answer = LikelySmiBinaryOperation(expr, &left, &right, overwrite_mode); |
| 1045 } else { | 1045 } else { |
| 1046 GenericBinaryOpStub stub(op, | 1046 GenericBinaryOpStub stub(op, |
| 1047 overwrite_mode, | 1047 overwrite_mode, |
| 1048 NO_GENERIC_BINARY_FLAGS, | 1048 NO_GENERIC_BINARY_FLAGS, |
| 1049 operands_type); | 1049 operands_type); |
| 1050 answer = stub.GenerateCall(masm_, frame_, &left, &right); | 1050 answer = GenerateGenericBinaryOpStubCall(&stub, &left, &right); |
| 1051 } | 1051 } |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 answer.set_type_info(result_type); | 1054 answer.set_type_info(result_type); |
| 1055 frame_->Push(&answer); | 1055 frame_->Push(&answer); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 | 1058 |
| 1059 bool CodeGenerator::FoldConstantSmis(Token::Value op, int left, int right) { | 1059 bool CodeGenerator::FoldConstantSmis(Token::Value op, int left, int right) { |
| 1060 Object* answer_object = Heap::undefined_value(); | 1060 Object* answer_object = Heap::undefined_value(); |
| (...skipping 7721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8782 break; | 8782 break; |
| 8783 } | 8783 } |
| 8784 | 8784 |
| 8785 case UNLOADED: | 8785 case UNLOADED: |
| 8786 case ILLEGAL: | 8786 case ILLEGAL: |
| 8787 UNREACHABLE(); | 8787 UNREACHABLE(); |
| 8788 } | 8788 } |
| 8789 } | 8789 } |
| 8790 | 8790 |
| 8791 | 8791 |
| 8792 Result GenericBinaryOpStub::GenerateCall(MacroAssembler* masm, | 8792 Result CodeGenerator::GenerateGenericBinaryOpStubCall(GenericBinaryOpStub* stub, |
| 8793 VirtualFrame* frame, | 8793 Result* left, |
| 8794 Result* left, | 8794 Result* right) { |
| 8795 Result* right) { | 8795 if (stub->ArgsInRegistersSupported()) { |
| 8796 if (ArgsInRegistersSupported()) { | 8796 stub->SetArgsInRegisters(); |
| 8797 SetArgsInRegisters(); | 8797 return frame_->CallStub(stub, left, right); |
| 8798 return frame->CallStub(this, left, right); | |
| 8799 } else { | 8798 } else { |
| 8800 frame->Push(left); | 8799 frame_->Push(left); |
| 8801 frame->Push(right); | 8800 frame_->Push(right); |
| 8802 return frame->CallStub(this, 2); | 8801 return frame_->CallStub(stub, 2); |
| 8803 } | 8802 } |
| 8804 } | 8803 } |
| 8805 | 8804 |
| 8806 #undef __ | 8805 #undef __ |
| 8807 | 8806 |
| 8808 #define __ masm. | 8807 #define __ masm. |
| 8809 | 8808 |
| 8810 #ifdef _WIN64 | 8809 #ifdef _WIN64 |
| 8811 typedef double (*ModuloFunction)(double, double); | 8810 typedef double (*ModuloFunction)(double, double); |
| 8812 // Define custom fmod implementation. | 8811 // Define custom fmod implementation. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8900 #undef __ | 8899 #undef __ |
| 8901 | 8900 |
| 8902 void RecordWriteStub::Generate(MacroAssembler* masm) { | 8901 void RecordWriteStub::Generate(MacroAssembler* masm) { |
| 8903 masm->RecordWriteHelper(object_, addr_, scratch_); | 8902 masm->RecordWriteHelper(object_, addr_, scratch_); |
| 8904 masm->ret(0); | 8903 masm->ret(0); |
| 8905 } | 8904 } |
| 8906 | 8905 |
| 8907 } } // namespace v8::internal | 8906 } } // namespace v8::internal |
| 8908 | 8907 |
| 8909 #endif // V8_TARGET_ARCH_X64 | 8908 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |