| 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 21 matching lines...) Expand all Loading... |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 #include "bootstrapper.h" | 33 #include "bootstrapper.h" |
| 34 #include "jsregexp.h" | 34 #include "jsregexp.h" |
| 35 #include "isolate.h" | 35 #include "isolate.h" |
| 36 #include "regexp-macro-assembler.h" | 36 #include "regexp-macro-assembler.h" |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 #define __ ACCESS_MASM(masm) | 41 #define __ ACCESS_MASM(masm) |
| 42 |
| 43 void ToNumberStub::Generate(MacroAssembler* masm) { |
| 44 // The ToNumber stub takes one argument in eax. |
| 45 NearLabel check_heap_number, call_builtin; |
| 46 __ test(eax, Immediate(kSmiTagMask)); |
| 47 __ j(not_zero, &check_heap_number); |
| 48 __ ret(0); |
| 49 |
| 50 __ bind(&check_heap_number); |
| 51 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 52 __ cmp(Operand(ebx), Immediate(FACTORY->heap_number_map())); |
| 53 __ j(not_equal, &call_builtin); |
| 54 __ ret(0); |
| 55 |
| 56 __ bind(&call_builtin); |
| 57 __ pop(ecx); // Pop return address. |
| 58 __ push(eax); |
| 59 __ push(ecx); // Push return address. |
| 60 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); |
| 61 } |
| 62 |
| 63 |
| 42 void FastNewClosureStub::Generate(MacroAssembler* masm) { | 64 void FastNewClosureStub::Generate(MacroAssembler* masm) { |
| 43 // Create a new closure from the given function info in new | 65 // Create a new closure from the given function info in new |
| 44 // space. Set the context to the current context in esi. | 66 // space. Set the context to the current context in esi. |
| 45 Label gc; | 67 Label gc; |
| 46 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); | 68 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); |
| 47 | 69 |
| 48 // Get the function info from the stack. | 70 // Get the function info from the stack. |
| 49 __ mov(edx, Operand(esp, 1 * kPointerSize)); | 71 __ mov(edx, Operand(esp, 1 * kPointerSize)); |
| 50 | 72 |
| 51 // Compute the function map in the current global context and set that | 73 // Compute the function map in the current global context and set that |
| (...skipping 3424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 // Test for -0.5. | 3498 // Test for -0.5. |
| 3477 // Load xmm2 with -0.5. | 3499 // Load xmm2 with -0.5. |
| 3478 __ mov(ecx, Immediate(0xBF000000)); | 3500 __ mov(ecx, Immediate(0xBF000000)); |
| 3479 __ movd(xmm2, Operand(ecx)); | 3501 __ movd(xmm2, Operand(ecx)); |
| 3480 __ cvtss2sd(xmm2, xmm2); | 3502 __ cvtss2sd(xmm2, xmm2); |
| 3481 // xmm2 now has -0.5. | 3503 // xmm2 now has -0.5. |
| 3482 __ ucomisd(xmm2, xmm1); | 3504 __ ucomisd(xmm2, xmm1); |
| 3483 __ j(not_equal, ¬_minus_half); | 3505 __ j(not_equal, ¬_minus_half); |
| 3484 | 3506 |
| 3485 // Calculates reciprocal of square root. | 3507 // Calculates reciprocal of square root. |
| 3486 // Note that 1/sqrt(x) = sqrt(1/x)) | 3508 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 3487 __ divsd(xmm3, xmm0); | 3509 __ xorpd(xmm1, xmm1); |
| 3510 __ addsd(xmm1, xmm0); |
| 3511 __ sqrtsd(xmm1, xmm1); |
| 3512 __ divsd(xmm3, xmm1); |
| 3488 __ movsd(xmm1, xmm3); | 3513 __ movsd(xmm1, xmm3); |
| 3489 __ sqrtsd(xmm1, xmm1); | |
| 3490 __ jmp(&allocate_return); | 3514 __ jmp(&allocate_return); |
| 3491 | 3515 |
| 3492 // Test for 0.5. | 3516 // Test for 0.5. |
| 3493 __ bind(¬_minus_half); | 3517 __ bind(¬_minus_half); |
| 3494 // Load xmm2 with 0.5. | 3518 // Load xmm2 with 0.5. |
| 3495 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. | 3519 // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. |
| 3496 __ addsd(xmm2, xmm3); | 3520 __ addsd(xmm2, xmm3); |
| 3497 // xmm2 now has 0.5. | 3521 // xmm2 now has 0.5. |
| 3498 __ ucomisd(xmm2, xmm1); | 3522 __ ucomisd(xmm2, xmm1); |
| 3499 __ j(not_equal, &call_runtime); | 3523 __ j(not_equal, &call_runtime); |
| 3500 // Calculates square root. | 3524 // Calculates square root. |
| 3501 __ movsd(xmm1, xmm0); | 3525 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 3526 __ xorpd(xmm1, xmm1); |
| 3527 __ addsd(xmm1, xmm0); |
| 3502 __ sqrtsd(xmm1, xmm1); | 3528 __ sqrtsd(xmm1, xmm1); |
| 3503 | 3529 |
| 3504 __ bind(&allocate_return); | 3530 __ bind(&allocate_return); |
| 3505 __ AllocateHeapNumber(ecx, eax, edx, &call_runtime); | 3531 __ AllocateHeapNumber(ecx, eax, edx, &call_runtime); |
| 3506 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1); | 3532 __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1); |
| 3507 __ mov(eax, ecx); | 3533 __ mov(eax, ecx); |
| 3508 __ ret(2); | 3534 __ ret(2); |
| 3509 | 3535 |
| 3510 __ bind(&call_runtime); | 3536 __ bind(&call_runtime); |
| 3511 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); | 3537 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); |
| (...skipping 2986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6498 // Do a tail call to the rewritten stub. | 6524 // Do a tail call to the rewritten stub. |
| 6499 __ jmp(Operand(edi)); | 6525 __ jmp(Operand(edi)); |
| 6500 } | 6526 } |
| 6501 | 6527 |
| 6502 | 6528 |
| 6503 #undef __ | 6529 #undef __ |
| 6504 | 6530 |
| 6505 } } // namespace v8::internal | 6531 } } // namespace v8::internal |
| 6506 | 6532 |
| 6507 #endif // V8_TARGET_ARCH_IA32 | 6533 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |