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 10593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10604 case Token::MUL: | 10604 case Token::MUL: |
10605 case Token::DIV: { | 10605 case Token::DIV: { |
10606 if (runtime_operands_type_ == BinaryOpIC::DEFAULT && | 10606 if (runtime_operands_type_ == BinaryOpIC::DEFAULT && |
10607 HasSmiCodeInStub()) { | 10607 HasSmiCodeInStub()) { |
10608 // Execution reaches this point when the first non-smi argument occurs | 10608 // Execution reaches this point when the first non-smi argument occurs |
10609 // (and only if smi code is generated). This is the right moment to | 10609 // (and only if smi code is generated). This is the right moment to |
10610 // patch to HEAP_NUMBERS state. The transition is attempted only for | 10610 // patch to HEAP_NUMBERS state. The transition is attempted only for |
10611 // the four basic operations. The stub stays in the DEFAULT state | 10611 // the four basic operations. The stub stays in the DEFAULT state |
10612 // forever for all other operations (also if smi code is skipped). | 10612 // forever for all other operations (also if smi code is skipped). |
10613 GenerateTypeTransition(masm); | 10613 GenerateTypeTransition(masm); |
| 10614 break; |
10614 } | 10615 } |
10615 | 10616 |
10616 Label not_floats; | 10617 Label not_floats; |
10617 // rax: y | 10618 // rax: y |
10618 // rdx: x | 10619 // rdx: x |
10619 if (static_operands_type_.IsNumber()) { | 10620 if (static_operands_type_.IsNumber()) { |
10620 if (FLAG_debug_code) { | 10621 if (FLAG_debug_code) { |
10621 // Assert at runtime that inputs are only numbers. | 10622 // Assert at runtime that inputs are only numbers. |
10622 __ AbortIfNotNumber(rdx); | 10623 __ AbortIfNotNumber(rdx); |
10623 __ AbortIfNotNumber(rax); | 10624 __ AbortIfNotNumber(rax); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10921 __ push(rdx); | 10922 __ push(rdx); |
10922 __ push(rax); | 10923 __ push(rax); |
10923 } | 10924 } |
10924 __ push(rcx); | 10925 __ push(rcx); |
10925 } | 10926 } |
10926 | 10927 |
10927 | 10928 |
10928 void GenericBinaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { | 10929 void GenericBinaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { |
10929 Label get_result; | 10930 Label get_result; |
10930 | 10931 |
10931 // Keep a copy of operands on the stack and make sure they are also in | 10932 // Ensure the operands are on the stack. |
10932 // rdx, rax. | |
10933 if (HasArgsInRegisters()) { | 10933 if (HasArgsInRegisters()) { |
10934 GenerateRegisterArgsPush(masm); | 10934 GenerateRegisterArgsPush(masm); |
10935 } else { | |
10936 GenerateLoadArguments(masm); | |
10937 } | 10935 } |
10938 | 10936 |
10939 // Internal frame is necessary to handle exceptions properly. | |
10940 __ EnterInternalFrame(); | |
10941 | |
10942 // Push arguments on stack if the stub expects them there. | |
10943 if (!HasArgsInRegisters()) { | |
10944 __ push(rdx); | |
10945 __ push(rax); | |
10946 } | |
10947 // Call the stub proper to get the result in rax. | |
10948 __ call(&get_result); | |
10949 __ LeaveInternalFrame(); | |
10950 | |
10951 // Left and right arguments are already on stack. | 10937 // Left and right arguments are already on stack. |
10952 __ pop(rcx); | 10938 __ pop(rcx); // Save the return address. |
10953 // Push the operation result. The tail call to BinaryOp_Patch will | |
10954 // return it to the original caller.. | |
10955 __ push(rax); | |
10956 | 10939 |
10957 // Push this stub's key. | 10940 // Push this stub's key. |
10958 __ Push(Smi::FromInt(MinorKey())); | 10941 __ Push(Smi::FromInt(MinorKey())); |
10959 | 10942 |
10960 // Although the operation and the type info are encoded into the key, | 10943 // Although the operation and the type info are encoded into the key, |
10961 // the encoding is opaque, so push them too. | 10944 // the encoding is opaque, so push them too. |
10962 __ Push(Smi::FromInt(op_)); | 10945 __ Push(Smi::FromInt(op_)); |
10963 | 10946 |
10964 __ Push(Smi::FromInt(runtime_operands_type_)); | 10947 __ Push(Smi::FromInt(runtime_operands_type_)); |
10965 | 10948 |
10966 __ push(rcx); | 10949 __ push(rcx); // The return address. |
10967 | 10950 |
10968 // Perform patching to an appropriate fast case and return the result. | 10951 // Perform patching to an appropriate fast case and return the result. |
10969 __ TailCallExternalReference( | 10952 __ TailCallExternalReference( |
10970 ExternalReference(IC_Utility(IC::kBinaryOp_Patch)), | 10953 ExternalReference(IC_Utility(IC::kBinaryOp_Patch)), |
10971 6, | 10954 5, |
10972 1); | 10955 1); |
10973 | |
10974 // The entry point for the result calculation is assumed to be immediately | |
10975 // after this sequence. | |
10976 __ bind(&get_result); | |
10977 } | 10956 } |
10978 | 10957 |
10979 | 10958 |
10980 Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info) { | 10959 Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info) { |
10981 GenericBinaryOpStub stub(key, type_info); | 10960 GenericBinaryOpStub stub(key, type_info); |
10982 return stub.GetCode(); | 10961 return stub.GetCode(); |
10983 } | 10962 } |
10984 | 10963 |
10985 | 10964 |
10986 int CompareStub::MinorKey() { | 10965 int CompareStub::MinorKey() { |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12084 } | 12063 } |
12085 | 12064 |
12086 #endif | 12065 #endif |
12087 | 12066 |
12088 | 12067 |
12089 #undef __ | 12068 #undef __ |
12090 | 12069 |
12091 } } // namespace v8::internal | 12070 } } // namespace v8::internal |
12092 | 12071 |
12093 #endif // V8_TARGET_ARCH_X64 | 12072 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |