OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 &runtime, STRING_INDEX_IS_NUMBER, | 2910 &runtime, STRING_INDEX_IS_NUMBER, |
2911 RECEIVER_IS_STRING); | 2911 RECEIVER_IS_STRING); |
2912 generator.GenerateFast(masm); | 2912 generator.GenerateFast(masm); |
2913 __ ret(3 * kPointerSize); | 2913 __ ret(3 * kPointerSize); |
2914 generator.SkipSlow(masm, &runtime); | 2914 generator.SkipSlow(masm, &runtime); |
2915 } | 2915 } |
2916 | 2916 |
2917 | 2917 |
2918 void ToNumberStub::Generate(MacroAssembler* masm) { | 2918 void ToNumberStub::Generate(MacroAssembler* masm) { |
2919 // The ToNumber stub takes one argument in eax. | 2919 // The ToNumber stub takes one argument in eax. |
2920 Label check_heap_number, call_builtin; | 2920 Label not_smi; |
2921 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear); | 2921 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
2922 __ Ret(); | 2922 __ Ret(); |
| 2923 __ bind(¬_smi); |
2923 | 2924 |
2924 __ bind(&check_heap_number); | 2925 Label not_heap_number; |
2925 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); | 2926 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); |
2926 __ j(not_equal, &call_builtin, Label::kNear); | 2927 __ j(not_equal, ¬_heap_number, Label::kNear); |
2927 __ Ret(); | 2928 __ Ret(); |
| 2929 __ bind(¬_heap_number); |
2928 | 2930 |
2929 __ bind(&call_builtin); | 2931 Label not_string, slow_string; |
2930 __ pop(ecx); // Pop return address. | 2932 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
2931 __ push(eax); | 2933 // eax: object |
| 2934 // edi: object map |
| 2935 __ j(above_equal, ¬_string, Label::kNear); |
| 2936 // Check if string has a cached array index. |
| 2937 __ test(FieldOperand(eax, String::kHashFieldOffset), |
| 2938 Immediate(String::kContainsCachedArrayIndexMask)); |
| 2939 __ j(not_zero, &slow_string, Label::kNear); |
| 2940 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
| 2941 __ IndexFromHash(eax, eax); |
| 2942 __ Ret(); |
| 2943 __ bind(&slow_string); |
| 2944 __ pop(ecx); // Pop return address. |
| 2945 __ push(eax); // Push argument. |
| 2946 __ push(ecx); // Push return address. |
| 2947 __ TailCallRuntime(Runtime::kStringToNumber, 1, 1); |
| 2948 __ bind(¬_string); |
| 2949 |
| 2950 Label not_oddball; |
| 2951 __ CmpInstanceType(edi, ODDBALL_TYPE); |
| 2952 __ j(not_equal, ¬_oddball, Label::kNear); |
| 2953 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
| 2954 __ Ret(); |
| 2955 __ bind(¬_oddball); |
| 2956 |
| 2957 __ pop(ecx); // Pop return address. |
| 2958 __ push(eax); // Push argument. |
2932 __ push(ecx); // Push return address. | 2959 __ push(ecx); // Push return address. |
2933 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); | 2960 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); |
2934 } | 2961 } |
2935 | 2962 |
2936 | 2963 |
2937 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, | 2964 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
2938 Register left, | 2965 Register left, |
2939 Register right, | 2966 Register right, |
2940 Register scratch1, | 2967 Register scratch1, |
2941 Register scratch2) { | 2968 Register scratch2) { |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4472 Operand(ebp, 7 * kPointerSize), | 4499 Operand(ebp, 7 * kPointerSize), |
4473 NULL); | 4500 NULL); |
4474 } | 4501 } |
4475 | 4502 |
4476 | 4503 |
4477 #undef __ | 4504 #undef __ |
4478 | 4505 |
4479 } } // namespace v8::internal | 4506 } } // namespace v8::internal |
4480 | 4507 |
4481 #endif // V8_TARGET_ARCH_X87 | 4508 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |