| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4902 __ push(rcx); | 4902 __ push(rcx); |
| 4903 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); | 4903 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); |
| 4904 | 4904 |
| 4905 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 4905 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 4906 // tagged as a small integer. | 4906 // tagged as a small integer. |
| 4907 __ bind(&runtime); | 4907 __ bind(&runtime); |
| 4908 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 4908 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 4909 } | 4909 } |
| 4910 | 4910 |
| 4911 | 4911 |
| 4912 void StringCharAtStub::Generate(MacroAssembler* masm) { | |
| 4913 // Expects two arguments (object, index) on the stack: | |
| 4914 | |
| 4915 // Stack frame on entry. | |
| 4916 // rsp[0]: return address | |
| 4917 // rsp[8]: index | |
| 4918 // rsp[16]: object | |
| 4919 | |
| 4920 Register object = rbx; | |
| 4921 Register index = rax; | |
| 4922 Register scratch1 = rcx; | |
| 4923 Register scratch2 = rdx; | |
| 4924 Register result = rax; | |
| 4925 | |
| 4926 __ pop(scratch1); // Return address. | |
| 4927 __ pop(index); | |
| 4928 __ pop(object); | |
| 4929 __ push(scratch1); | |
| 4930 | |
| 4931 Label need_conversion; | |
| 4932 Label index_out_of_range; | |
| 4933 Label done; | |
| 4934 StringCharAtGenerator generator(object, | |
| 4935 index, | |
| 4936 scratch1, | |
| 4937 scratch2, | |
| 4938 result, | |
| 4939 &need_conversion, | |
| 4940 &need_conversion, | |
| 4941 &index_out_of_range, | |
| 4942 STRING_INDEX_IS_NUMBER); | |
| 4943 generator.GenerateFast(masm); | |
| 4944 __ jmp(&done); | |
| 4945 | |
| 4946 __ bind(&index_out_of_range); | |
| 4947 // When the index is out of range, the spec requires us to return | |
| 4948 // the empty string. | |
| 4949 __ LoadRoot(result, Heap::kEmptyStringRootIndex); | |
| 4950 __ jmp(&done); | |
| 4951 | |
| 4952 __ bind(&need_conversion); | |
| 4953 // Move smi zero into the result register, which will trigger | |
| 4954 // conversion. | |
| 4955 __ Move(result, Smi::FromInt(0)); | |
| 4956 __ jmp(&done); | |
| 4957 | |
| 4958 StubRuntimeCallHelper call_helper; | |
| 4959 generator.GenerateSlow(masm, call_helper); | |
| 4960 | |
| 4961 __ bind(&done); | |
| 4962 __ ret(0); | |
| 4963 } | |
| 4964 | |
| 4965 | |
| 4966 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { | 4912 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { |
| 4967 ASSERT(state_ == CompareIC::SMIS); | 4913 ASSERT(state_ == CompareIC::SMIS); |
| 4968 NearLabel miss; | 4914 NearLabel miss; |
| 4969 __ JumpIfNotBothSmi(rdx, rax, &miss); | 4915 __ JumpIfNotBothSmi(rdx, rax, &miss); |
| 4970 | 4916 |
| 4971 if (GetCondition() == equal) { | 4917 if (GetCondition() == equal) { |
| 4972 // For equality we do not care about the sign of the result. | 4918 // For equality we do not care about the sign of the result. |
| 4973 __ subq(rax, rdx); | 4919 __ subq(rax, rdx); |
| 4974 } else { | 4920 } else { |
| 4975 NearLabel done; | 4921 NearLabel done; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5078 // Do a tail call to the rewritten stub. | 5024 // Do a tail call to the rewritten stub. |
| 5079 __ jmp(rdi); | 5025 __ jmp(rdi); |
| 5080 } | 5026 } |
| 5081 | 5027 |
| 5082 | 5028 |
| 5083 #undef __ | 5029 #undef __ |
| 5084 | 5030 |
| 5085 } } // namespace v8::internal | 5031 } } // namespace v8::internal |
| 5086 | 5032 |
| 5087 #endif // V8_TARGET_ARCH_X64 | 5033 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |