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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 &runtime, STRING_INDEX_IS_NUMBER, | 3220 &runtime, STRING_INDEX_IS_NUMBER, |
3221 RECEIVER_IS_STRING); | 3221 RECEIVER_IS_STRING); |
3222 generator.GenerateFast(masm); | 3222 generator.GenerateFast(masm); |
3223 __ ret(3 * kPointerSize); | 3223 __ ret(3 * kPointerSize); |
3224 generator.SkipSlow(masm, &runtime); | 3224 generator.SkipSlow(masm, &runtime); |
3225 } | 3225 } |
3226 | 3226 |
3227 | 3227 |
3228 void ToNumberStub::Generate(MacroAssembler* masm) { | 3228 void ToNumberStub::Generate(MacroAssembler* masm) { |
3229 // The ToNumber stub takes one argument in eax. | 3229 // The ToNumber stub takes one argument in eax. |
3230 Label check_heap_number, call_builtin; | 3230 Label not_smi; |
3231 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear); | 3231 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
3232 __ Ret(); | 3232 __ Ret(); |
| 3233 __ bind(¬_smi); |
3233 | 3234 |
3234 __ bind(&check_heap_number); | 3235 Label not_heap_number; |
3235 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); | 3236 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); |
3236 __ j(not_equal, &call_builtin, Label::kNear); | 3237 __ j(not_equal, ¬_heap_number, Label::kNear); |
3237 __ Ret(); | 3238 __ Ret(); |
| 3239 __ bind(¬_heap_number); |
3238 | 3240 |
3239 __ bind(&call_builtin); | 3241 Label not_string, slow_string; |
3240 __ pop(ecx); // Pop return address. | 3242 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
3241 __ push(eax); | 3243 // eax: object |
| 3244 // edi: object map |
| 3245 __ j(above_equal, ¬_string, Label::kNear); |
| 3246 // Check if string has a cached array index. |
| 3247 __ test(FieldOperand(eax, String::kHashFieldOffset), |
| 3248 Immediate(String::kContainsCachedArrayIndexMask)); |
| 3249 __ j(not_zero, &slow_string, Label::kNear); |
| 3250 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
| 3251 __ IndexFromHash(eax, eax); |
| 3252 __ Ret(); |
| 3253 __ bind(&slow_string); |
| 3254 __ pop(ecx); // Pop return address. |
| 3255 __ push(eax); // Push argument. |
| 3256 __ push(ecx); // Push return address. |
| 3257 __ TailCallRuntime(Runtime::kStringToNumber, 1, 1); |
| 3258 __ bind(¬_string); |
| 3259 |
| 3260 Label not_oddball; |
| 3261 __ CmpInstanceType(edi, ODDBALL_TYPE); |
| 3262 __ j(not_equal, ¬_oddball, Label::kNear); |
| 3263 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
| 3264 __ Ret(); |
| 3265 __ bind(¬_oddball); |
| 3266 |
| 3267 __ pop(ecx); // Pop return address. |
| 3268 __ push(eax); // Push argument. |
3242 __ push(ecx); // Push return address. | 3269 __ push(ecx); // Push return address. |
3243 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); | 3270 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); |
3244 } | 3271 } |
3245 | 3272 |
3246 | 3273 |
3247 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, | 3274 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
3248 Register left, | 3275 Register left, |
3249 Register right, | 3276 Register right, |
3250 Register scratch1, | 3277 Register scratch1, |
3251 Register scratch2) { | 3278 Register scratch2) { |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4812 Operand(ebp, 7 * kPointerSize), | 4839 Operand(ebp, 7 * kPointerSize), |
4813 NULL); | 4840 NULL); |
4814 } | 4841 } |
4815 | 4842 |
4816 | 4843 |
4817 #undef __ | 4844 #undef __ |
4818 | 4845 |
4819 } } // namespace v8::internal | 4846 } } // namespace v8::internal |
4820 | 4847 |
4821 #endif // V8_TARGET_ARCH_IA32 | 4848 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |