| 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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2469 | 2469 |
| 2470 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { | 2470 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
| 2471 // The NonNumberToNumber stub takes one argument in eax. | 2471 // The NonNumberToNumber stub takes one argument in eax. |
| 2472 __ AssertNotNumber(eax); | 2472 __ AssertNotNumber(eax); |
| 2473 | 2473 |
| 2474 Label not_string; | 2474 Label not_string; |
| 2475 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); | 2475 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
| 2476 // eax: object | 2476 // eax: object |
| 2477 // edi: object map | 2477 // edi: object map |
| 2478 __ j(above_equal, ¬_string, Label::kNear); | 2478 __ j(above_equal, ¬_string, Label::kNear); |
| 2479 StringToNumberStub stub(masm->isolate()); | 2479 __ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET); |
| 2480 __ TailCallStub(&stub); | |
| 2481 __ bind(¬_string); | 2480 __ bind(¬_string); |
| 2482 | 2481 |
| 2483 Label not_oddball; | 2482 Label not_oddball; |
| 2484 __ CmpInstanceType(edi, ODDBALL_TYPE); | 2483 __ CmpInstanceType(edi, ODDBALL_TYPE); |
| 2485 __ j(not_equal, ¬_oddball, Label::kNear); | 2484 __ j(not_equal, ¬_oddball, Label::kNear); |
| 2486 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); | 2485 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
| 2487 __ Ret(); | 2486 __ Ret(); |
| 2488 __ bind(¬_oddball); | 2487 __ bind(¬_oddball); |
| 2489 | 2488 |
| 2490 __ pop(ecx); // Pop return address. | 2489 __ pop(ecx); // Pop return address. |
| 2491 __ push(eax); // Push argument. | 2490 __ push(eax); // Push argument. |
| 2492 __ push(ecx); // Push return address. | 2491 __ push(ecx); // Push return address. |
| 2493 __ TailCallRuntime(Runtime::kToNumber); | 2492 __ TailCallRuntime(Runtime::kToNumber); |
| 2494 } | 2493 } |
| 2495 | 2494 |
| 2496 void StringToNumberStub::Generate(MacroAssembler* masm) { | |
| 2497 // The StringToNumber stub takes one argument in eax. | |
| 2498 __ AssertString(eax); | |
| 2499 | |
| 2500 // Check if string has a cached array index. | |
| 2501 Label runtime; | |
| 2502 __ test(FieldOperand(eax, String::kHashFieldOffset), | |
| 2503 Immediate(String::kContainsCachedArrayIndexMask)); | |
| 2504 __ j(not_zero, &runtime, Label::kNear); | |
| 2505 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); | |
| 2506 __ IndexFromHash(eax, eax); | |
| 2507 __ Ret(); | |
| 2508 | |
| 2509 __ bind(&runtime); | |
| 2510 __ PopReturnAddressTo(ecx); // Pop return address. | |
| 2511 __ Push(eax); // Push argument. | |
| 2512 __ PushReturnAddressFrom(ecx); // Push return address. | |
| 2513 __ TailCallRuntime(Runtime::kStringToNumber); | |
| 2514 } | |
| 2515 | |
| 2516 void ToStringStub::Generate(MacroAssembler* masm) { | 2495 void ToStringStub::Generate(MacroAssembler* masm) { |
| 2517 // The ToString stub takes one argument in eax. | 2496 // The ToString stub takes one argument in eax. |
| 2518 Label is_number; | 2497 Label is_number; |
| 2519 __ JumpIfSmi(eax, &is_number, Label::kNear); | 2498 __ JumpIfSmi(eax, &is_number, Label::kNear); |
| 2520 | 2499 |
| 2521 Label not_string; | 2500 Label not_string; |
| 2522 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); | 2501 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
| 2523 // eax: receiver | 2502 // eax: receiver |
| 2524 // edi: receiver map | 2503 // edi: receiver map |
| 2525 __ j(above_equal, ¬_string, Label::kNear); | 2504 __ j(above_equal, ¬_string, Label::kNear); |
| (...skipping 3197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5723 kStackUnwindSpace, nullptr, return_value_operand, | 5702 kStackUnwindSpace, nullptr, return_value_operand, |
| 5724 NULL); | 5703 NULL); |
| 5725 } | 5704 } |
| 5726 | 5705 |
| 5727 #undef __ | 5706 #undef __ |
| 5728 | 5707 |
| 5729 } // namespace internal | 5708 } // namespace internal |
| 5730 } // namespace v8 | 5709 } // namespace v8 |
| 5731 | 5710 |
| 5732 #endif // V8_TARGET_ARCH_IA32 | 5711 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |