| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 &runtime, STRING_INDEX_IS_NUMBER, | 3162 &runtime, STRING_INDEX_IS_NUMBER, |
| 3163 RECEIVER_IS_STRING); | 3163 RECEIVER_IS_STRING); |
| 3164 generator.GenerateFast(masm); | 3164 generator.GenerateFast(masm); |
| 3165 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize); | 3165 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize); |
| 3166 generator.SkipSlow(masm, &runtime); | 3166 generator.SkipSlow(masm, &runtime); |
| 3167 } | 3167 } |
| 3168 | 3168 |
| 3169 | 3169 |
| 3170 void ToNumberStub::Generate(MacroAssembler* masm) { | 3170 void ToNumberStub::Generate(MacroAssembler* masm) { |
| 3171 // The ToNumber stub takes one argument in rax. | 3171 // The ToNumber stub takes one argument in rax. |
| 3172 Label check_heap_number, call_builtin; | 3172 Label not_smi; |
| 3173 __ JumpIfNotSmi(rax, &check_heap_number, Label::kNear); | 3173 __ JumpIfNotSmi(rax, ¬_smi, Label::kNear); |
| 3174 __ Ret(); | 3174 __ Ret(); |
| 3175 __ bind(¬_smi); |
| 3175 | 3176 |
| 3176 __ bind(&check_heap_number); | 3177 Label not_heap_number; |
| 3177 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), | 3178 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), |
| 3178 Heap::kHeapNumberMapRootIndex); | 3179 Heap::kHeapNumberMapRootIndex); |
| 3179 __ j(not_equal, &call_builtin, Label::kNear); | 3180 __ j(not_equal, ¬_heap_number, Label::kNear); |
| 3180 __ Ret(); | 3181 __ Ret(); |
| 3182 __ bind(¬_heap_number); |
| 3181 | 3183 |
| 3182 __ bind(&call_builtin); | 3184 Label not_string, slow_string; |
| 3183 __ popq(rcx); // Pop return address. | 3185 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); |
| 3184 __ pushq(rax); | 3186 // rax: object |
| 3185 __ pushq(rcx); // Push return address. | 3187 // rdi: object map |
| 3188 __ j(above_equal, ¬_string, Label::kNear); |
| 3189 // Check if string has a cached array index. |
| 3190 __ testl(FieldOperand(rax, String::kHashFieldOffset), |
| 3191 Immediate(String::kContainsCachedArrayIndexMask)); |
| 3192 __ j(not_zero, &slow_string, Label::kNear); |
| 3193 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
| 3194 __ IndexFromHash(rax, rax); |
| 3195 __ Ret(); |
| 3196 __ bind(&slow_string); |
| 3197 __ PopReturnAddressTo(rcx); // Pop return address. |
| 3198 __ Push(rax); // Push argument. |
| 3199 __ PushReturnAddressFrom(rcx); // Push return address. |
| 3200 __ TailCallRuntime(Runtime::kStringToNumber, 1, 1); |
| 3201 __ bind(¬_string); |
| 3202 |
| 3203 Label not_oddball; |
| 3204 __ CmpInstanceType(rdi, ODDBALL_TYPE); |
| 3205 __ j(not_equal, ¬_oddball, Label::kNear); |
| 3206 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); |
| 3207 __ Ret(); |
| 3208 __ bind(¬_oddball); |
| 3209 |
| 3210 __ PopReturnAddressTo(rcx); // Pop return address. |
| 3211 __ Push(rax); // Push argument. |
| 3212 __ PushReturnAddressFrom(rcx); // Push return address. |
| 3186 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); | 3213 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); |
| 3187 } | 3214 } |
| 3188 | 3215 |
| 3189 | 3216 |
| 3190 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, | 3217 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
| 3191 Register left, | 3218 Register left, |
| 3192 Register right, | 3219 Register right, |
| 3193 Register scratch1, | 3220 Register scratch1, |
| 3194 Register scratch2) { | 3221 Register scratch2) { |
| 3195 Register length = scratch1; | 3222 Register length = scratch1; |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4772 return_value_operand, | 4799 return_value_operand, |
| 4773 NULL); | 4800 NULL); |
| 4774 } | 4801 } |
| 4775 | 4802 |
| 4776 | 4803 |
| 4777 #undef __ | 4804 #undef __ |
| 4778 | 4805 |
| 4779 } } // namespace v8::internal | 4806 } } // namespace v8::internal |
| 4780 | 4807 |
| 4781 #endif // V8_TARGET_ARCH_X64 | 4808 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |