| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3760 __ jmp(&loop); | 3760 __ jmp(&loop); |
| 3761 | 3761 |
| 3762 __ bind(&done); | 3762 __ bind(&done); |
| 3763 __ ret(3 * kPointerSize); | 3763 __ ret(3 * kPointerSize); |
| 3764 | 3764 |
| 3765 __ bind(&slowcase); | 3765 __ bind(&slowcase); |
| 3766 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); | 3766 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); |
| 3767 } | 3767 } |
| 3768 | 3768 |
| 3769 | 3769 |
| 3770 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, | |
| 3771 Register object, | |
| 3772 Register result, | |
| 3773 Register scratch1, | |
| 3774 Register scratch2, | |
| 3775 Label* not_found) { | |
| 3776 // Use of registers. Register result is used as a temporary. | |
| 3777 Register number_string_cache = result; | |
| 3778 Register mask = scratch1; | |
| 3779 Register scratch = scratch2; | |
| 3780 | |
| 3781 // Load the number string cache. | |
| 3782 __ LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex); | |
| 3783 // Make the hash mask from the length of the number string cache. It | |
| 3784 // contains two elements (number and string) for each cache entry. | |
| 3785 __ mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset)); | |
| 3786 __ shr(mask, kSmiTagSize + 1); // Untag length and divide it by two. | |
| 3787 __ sub(mask, Immediate(1)); // Make mask. | |
| 3788 | |
| 3789 // Calculate the entry in the number string cache. The hash value in the | |
| 3790 // number string cache for smis is just the smi value, and the hash for | |
| 3791 // doubles is the xor of the upper and lower words. See | |
| 3792 // Heap::GetNumberStringCache. | |
| 3793 Label smi_hash_calculated; | |
| 3794 Label load_result_from_cache; | |
| 3795 Label not_smi; | |
| 3796 STATIC_ASSERT(kSmiTag == 0); | |
| 3797 __ JumpIfNotSmi(object, ¬_smi, Label::kNear); | |
| 3798 __ mov(scratch, object); | |
| 3799 __ SmiUntag(scratch); | |
| 3800 __ jmp(&smi_hash_calculated, Label::kNear); | |
| 3801 __ bind(¬_smi); | |
| 3802 __ cmp(FieldOperand(object, HeapObject::kMapOffset), | |
| 3803 masm->isolate()->factory()->heap_number_map()); | |
| 3804 __ j(not_equal, not_found); | |
| 3805 STATIC_ASSERT(8 == kDoubleSize); | |
| 3806 __ mov(scratch, FieldOperand(object, HeapNumber::kValueOffset)); | |
| 3807 __ xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); | |
| 3808 // Object is heap number and hash is now in scratch. Calculate cache index. | |
| 3809 __ and_(scratch, mask); | |
| 3810 Register index = scratch; | |
| 3811 Register probe = mask; | |
| 3812 __ mov(probe, | |
| 3813 FieldOperand(number_string_cache, | |
| 3814 index, | |
| 3815 times_twice_pointer_size, | |
| 3816 FixedArray::kHeaderSize)); | |
| 3817 __ JumpIfSmi(probe, not_found); | |
| 3818 if (CpuFeatures::IsSupported(SSE2)) { | |
| 3819 CpuFeatureScope fscope(masm, SSE2); | |
| 3820 __ movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset)); | |
| 3821 __ movdbl(xmm1, FieldOperand(probe, HeapNumber::kValueOffset)); | |
| 3822 __ ucomisd(xmm0, xmm1); | |
| 3823 } else { | |
| 3824 __ fld_d(FieldOperand(object, HeapNumber::kValueOffset)); | |
| 3825 __ fld_d(FieldOperand(probe, HeapNumber::kValueOffset)); | |
| 3826 __ FCmp(); | |
| 3827 } | |
| 3828 __ j(parity_even, not_found); // Bail out if NaN is involved. | |
| 3829 __ j(not_equal, not_found); // The cache did not contain this value. | |
| 3830 __ jmp(&load_result_from_cache, Label::kNear); | |
| 3831 | |
| 3832 __ bind(&smi_hash_calculated); | |
| 3833 // Object is smi and hash is now in scratch. Calculate cache index. | |
| 3834 __ and_(scratch, mask); | |
| 3835 // Check if the entry is the smi we are looking for. | |
| 3836 __ cmp(object, | |
| 3837 FieldOperand(number_string_cache, | |
| 3838 index, | |
| 3839 times_twice_pointer_size, | |
| 3840 FixedArray::kHeaderSize)); | |
| 3841 __ j(not_equal, not_found); | |
| 3842 | |
| 3843 // Get the result from the cache. | |
| 3844 __ bind(&load_result_from_cache); | |
| 3845 __ mov(result, | |
| 3846 FieldOperand(number_string_cache, | |
| 3847 index, | |
| 3848 times_twice_pointer_size, | |
| 3849 FixedArray::kHeaderSize + kPointerSize)); | |
| 3850 Counters* counters = masm->isolate()->counters(); | |
| 3851 __ IncrementCounter(counters->number_to_string_native(), 1); | |
| 3852 } | |
| 3853 | |
| 3854 | |
| 3855 void NumberToStringStub::Generate(MacroAssembler* masm) { | 3770 void NumberToStringStub::Generate(MacroAssembler* masm) { |
| 3856 Label runtime; | 3771 Label runtime; |
| 3857 | 3772 |
| 3858 __ mov(ebx, Operand(esp, kPointerSize)); | 3773 __ mov(ebx, Operand(esp, kPointerSize)); |
| 3859 | 3774 |
| 3860 // Generate code to lookup number in the number string cache. | 3775 // Generate code to lookup number in the number string cache. |
| 3861 GenerateLookupNumberStringCache(masm, ebx, eax, ecx, edx, &runtime); | 3776 __ LookupNumberStringCache(ebx, eax, ecx, edx, &runtime); |
| 3862 __ ret(1 * kPointerSize); | 3777 __ ret(1 * kPointerSize); |
| 3863 | 3778 |
| 3864 __ bind(&runtime); | 3779 __ bind(&runtime); |
| 3865 // Handle number to string in the runtime system if not found in the cache. | 3780 // Handle number to string in the runtime system if not found in the cache. |
| 3866 __ TailCallRuntime(Runtime::kNumberToStringSkipCache, 1, 1); | 3781 __ TailCallRuntime(Runtime::kNumberToStringSkipCache, 1, 1); |
| 3867 } | 3782 } |
| 3868 | 3783 |
| 3869 | 3784 |
| 3870 static int NegativeComparisonResult(Condition cc) { | 3785 static int NegativeComparisonResult(Condition cc) { |
| 3871 ASSERT(cc != equal); | 3786 ASSERT(cc != equal); |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5511 Label* slow) { | 5426 Label* slow) { |
| 5512 // First check if the argument is already a string. | 5427 // First check if the argument is already a string. |
| 5513 Label not_string, done; | 5428 Label not_string, done; |
| 5514 __ JumpIfSmi(arg, ¬_string); | 5429 __ JumpIfSmi(arg, ¬_string); |
| 5515 __ CmpObjectType(arg, FIRST_NONSTRING_TYPE, scratch1); | 5430 __ CmpObjectType(arg, FIRST_NONSTRING_TYPE, scratch1); |
| 5516 __ j(below, &done); | 5431 __ j(below, &done); |
| 5517 | 5432 |
| 5518 // Check the number to string cache. | 5433 // Check the number to string cache. |
| 5519 __ bind(¬_string); | 5434 __ bind(¬_string); |
| 5520 // Puts the cached result into scratch1. | 5435 // Puts the cached result into scratch1. |
| 5521 NumberToStringStub::GenerateLookupNumberStringCache(masm, | 5436 __ LookupNumberStringCache(arg, scratch1, scratch2, scratch3, slow); |
| 5522 arg, | |
| 5523 scratch1, | |
| 5524 scratch2, | |
| 5525 scratch3, | |
| 5526 slow); | |
| 5527 __ mov(arg, scratch1); | 5437 __ mov(arg, scratch1); |
| 5528 __ mov(Operand(esp, stack_offset), arg); | 5438 __ mov(Operand(esp, stack_offset), arg); |
| 5529 __ bind(&done); | 5439 __ bind(&done); |
| 5530 } | 5440 } |
| 5531 | 5441 |
| 5532 | 5442 |
| 5533 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, | 5443 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, |
| 5534 Register dest, | 5444 Register dest, |
| 5535 Register src, | 5445 Register src, |
| 5536 Register count, | 5446 Register count, |
| (...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7547 __ bind(&fast_elements_case); | 7457 __ bind(&fast_elements_case); |
| 7548 GenerateCase(masm, FAST_ELEMENTS); | 7458 GenerateCase(masm, FAST_ELEMENTS); |
| 7549 } | 7459 } |
| 7550 | 7460 |
| 7551 | 7461 |
| 7552 #undef __ | 7462 #undef __ |
| 7553 | 7463 |
| 7554 } } // namespace v8::internal | 7464 } } // namespace v8::internal |
| 7555 | 7465 |
| 7556 #endif // V8_TARGET_ARCH_IA32 | 7466 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |