| 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 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 __ bind(&slowcase); | 3965 __ bind(&slowcase); |
| 3966 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); | 3966 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); |
| 3967 } | 3967 } |
| 3968 | 3968 |
| 3969 | 3969 |
| 3970 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, | 3970 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, |
| 3971 Register object, | 3971 Register object, |
| 3972 Register result, | 3972 Register result, |
| 3973 Register scratch1, | 3973 Register scratch1, |
| 3974 Register scratch2, | 3974 Register scratch2, |
| 3975 bool object_is_smi, | |
| 3976 Label* not_found) { | 3975 Label* not_found) { |
| 3977 // Use of registers. Register result is used as a temporary. | 3976 // Use of registers. Register result is used as a temporary. |
| 3978 Register number_string_cache = result; | 3977 Register number_string_cache = result; |
| 3979 Register mask = scratch1; | 3978 Register mask = scratch1; |
| 3980 Register scratch = scratch2; | 3979 Register scratch = scratch2; |
| 3981 | 3980 |
| 3982 // Load the number string cache. | 3981 // Load the number string cache. |
| 3983 ExternalReference roots_array_start = | 3982 ExternalReference roots_array_start = |
| 3984 ExternalReference::roots_array_start(masm->isolate()); | 3983 ExternalReference::roots_array_start(masm->isolate()); |
| 3985 __ mov(scratch, Immediate(Heap::kNumberStringCacheRootIndex)); | 3984 __ mov(scratch, Immediate(Heap::kNumberStringCacheRootIndex)); |
| 3986 __ mov(number_string_cache, | 3985 __ mov(number_string_cache, |
| 3987 Operand::StaticArray(scratch, times_pointer_size, roots_array_start)); | 3986 Operand::StaticArray(scratch, times_pointer_size, roots_array_start)); |
| 3988 // Make the hash mask from the length of the number string cache. It | 3987 // Make the hash mask from the length of the number string cache. It |
| 3989 // contains two elements (number and string) for each cache entry. | 3988 // contains two elements (number and string) for each cache entry. |
| 3990 __ mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset)); | 3989 __ mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset)); |
| 3991 __ shr(mask, kSmiTagSize + 1); // Untag length and divide it by two. | 3990 __ shr(mask, kSmiTagSize + 1); // Untag length and divide it by two. |
| 3992 __ sub(mask, Immediate(1)); // Make mask. | 3991 __ sub(mask, Immediate(1)); // Make mask. |
| 3993 | 3992 |
| 3994 // Calculate the entry in the number string cache. The hash value in the | 3993 // Calculate the entry in the number string cache. The hash value in the |
| 3995 // number string cache for smis is just the smi value, and the hash for | 3994 // number string cache for smis is just the smi value, and the hash for |
| 3996 // doubles is the xor of the upper and lower words. See | 3995 // doubles is the xor of the upper and lower words. See |
| 3997 // Heap::GetNumberStringCache. | 3996 // Heap::GetNumberStringCache. |
| 3998 Label smi_hash_calculated; | 3997 Label smi_hash_calculated; |
| 3999 Label load_result_from_cache; | 3998 Label load_result_from_cache; |
| 4000 if (object_is_smi) { | 3999 Label not_smi; |
| 4001 __ mov(scratch, object); | 4000 STATIC_ASSERT(kSmiTag == 0); |
| 4002 __ SmiUntag(scratch); | 4001 __ JumpIfNotSmi(object, ¬_smi, Label::kNear); |
| 4002 __ mov(scratch, object); |
| 4003 __ SmiUntag(scratch); |
| 4004 __ jmp(&smi_hash_calculated, Label::kNear); |
| 4005 __ bind(¬_smi); |
| 4006 __ cmp(FieldOperand(object, HeapObject::kMapOffset), |
| 4007 masm->isolate()->factory()->heap_number_map()); |
| 4008 __ j(not_equal, not_found); |
| 4009 STATIC_ASSERT(8 == kDoubleSize); |
| 4010 __ mov(scratch, FieldOperand(object, HeapNumber::kValueOffset)); |
| 4011 __ xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); |
| 4012 // Object is heap number and hash is now in scratch. Calculate cache index. |
| 4013 __ and_(scratch, mask); |
| 4014 Register index = scratch; |
| 4015 Register probe = mask; |
| 4016 __ mov(probe, |
| 4017 FieldOperand(number_string_cache, |
| 4018 index, |
| 4019 times_twice_pointer_size, |
| 4020 FixedArray::kHeaderSize)); |
| 4021 __ JumpIfSmi(probe, not_found); |
| 4022 if (CpuFeatures::IsSupported(SSE2)) { |
| 4023 CpuFeatureScope fscope(masm, SSE2); |
| 4024 __ movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset)); |
| 4025 __ movdbl(xmm1, FieldOperand(probe, HeapNumber::kValueOffset)); |
| 4026 __ ucomisd(xmm0, xmm1); |
| 4003 } else { | 4027 } else { |
| 4004 Label not_smi; | 4028 __ fld_d(FieldOperand(object, HeapNumber::kValueOffset)); |
| 4005 STATIC_ASSERT(kSmiTag == 0); | 4029 __ fld_d(FieldOperand(probe, HeapNumber::kValueOffset)); |
| 4006 __ JumpIfNotSmi(object, ¬_smi, Label::kNear); | 4030 __ FCmp(); |
| 4007 __ mov(scratch, object); | |
| 4008 __ SmiUntag(scratch); | |
| 4009 __ jmp(&smi_hash_calculated, Label::kNear); | |
| 4010 __ bind(¬_smi); | |
| 4011 __ cmp(FieldOperand(object, HeapObject::kMapOffset), | |
| 4012 masm->isolate()->factory()->heap_number_map()); | |
| 4013 __ j(not_equal, not_found); | |
| 4014 STATIC_ASSERT(8 == kDoubleSize); | |
| 4015 __ mov(scratch, FieldOperand(object, HeapNumber::kValueOffset)); | |
| 4016 __ xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); | |
| 4017 // Object is heap number and hash is now in scratch. Calculate cache index. | |
| 4018 __ and_(scratch, mask); | |
| 4019 Register index = scratch; | |
| 4020 Register probe = mask; | |
| 4021 __ mov(probe, | |
| 4022 FieldOperand(number_string_cache, | |
| 4023 index, | |
| 4024 times_twice_pointer_size, | |
| 4025 FixedArray::kHeaderSize)); | |
| 4026 __ JumpIfSmi(probe, not_found); | |
| 4027 if (CpuFeatures::IsSupported(SSE2)) { | |
| 4028 CpuFeatureScope fscope(masm, SSE2); | |
| 4029 __ movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset)); | |
| 4030 __ movdbl(xmm1, FieldOperand(probe, HeapNumber::kValueOffset)); | |
| 4031 __ ucomisd(xmm0, xmm1); | |
| 4032 } else { | |
| 4033 __ fld_d(FieldOperand(object, HeapNumber::kValueOffset)); | |
| 4034 __ fld_d(FieldOperand(probe, HeapNumber::kValueOffset)); | |
| 4035 __ FCmp(); | |
| 4036 } | |
| 4037 __ j(parity_even, not_found); // Bail out if NaN is involved. | |
| 4038 __ j(not_equal, not_found); // The cache did not contain this value. | |
| 4039 __ jmp(&load_result_from_cache, Label::kNear); | |
| 4040 } | 4031 } |
| 4032 __ j(parity_even, not_found); // Bail out if NaN is involved. |
| 4033 __ j(not_equal, not_found); // The cache did not contain this value. |
| 4034 __ jmp(&load_result_from_cache, Label::kNear); |
| 4041 | 4035 |
| 4042 __ bind(&smi_hash_calculated); | 4036 __ bind(&smi_hash_calculated); |
| 4043 // Object is smi and hash is now in scratch. Calculate cache index. | 4037 // Object is smi and hash is now in scratch. Calculate cache index. |
| 4044 __ and_(scratch, mask); | 4038 __ and_(scratch, mask); |
| 4045 Register index = scratch; | |
| 4046 // Check if the entry is the smi we are looking for. | 4039 // Check if the entry is the smi we are looking for. |
| 4047 __ cmp(object, | 4040 __ cmp(object, |
| 4048 FieldOperand(number_string_cache, | 4041 FieldOperand(number_string_cache, |
| 4049 index, | 4042 index, |
| 4050 times_twice_pointer_size, | 4043 times_twice_pointer_size, |
| 4051 FixedArray::kHeaderSize)); | 4044 FixedArray::kHeaderSize)); |
| 4052 __ j(not_equal, not_found); | 4045 __ j(not_equal, not_found); |
| 4053 | 4046 |
| 4054 // Get the result from the cache. | 4047 // Get the result from the cache. |
| 4055 __ bind(&load_result_from_cache); | 4048 __ bind(&load_result_from_cache); |
| 4056 __ mov(result, | 4049 __ mov(result, |
| 4057 FieldOperand(number_string_cache, | 4050 FieldOperand(number_string_cache, |
| 4058 index, | 4051 index, |
| 4059 times_twice_pointer_size, | 4052 times_twice_pointer_size, |
| 4060 FixedArray::kHeaderSize + kPointerSize)); | 4053 FixedArray::kHeaderSize + kPointerSize)); |
| 4061 Counters* counters = masm->isolate()->counters(); | 4054 Counters* counters = masm->isolate()->counters(); |
| 4062 __ IncrementCounter(counters->number_to_string_native(), 1); | 4055 __ IncrementCounter(counters->number_to_string_native(), 1); |
| 4063 } | 4056 } |
| 4064 | 4057 |
| 4065 | 4058 |
| 4066 void NumberToStringStub::Generate(MacroAssembler* masm) { | 4059 void NumberToStringStub::Generate(MacroAssembler* masm) { |
| 4067 Label runtime; | 4060 Label runtime; |
| 4068 | 4061 |
| 4069 __ mov(ebx, Operand(esp, kPointerSize)); | 4062 __ mov(ebx, Operand(esp, kPointerSize)); |
| 4070 | 4063 |
| 4071 // Generate code to lookup number in the number string cache. | 4064 // Generate code to lookup number in the number string cache. |
| 4072 GenerateLookupNumberStringCache(masm, ebx, eax, ecx, edx, false, &runtime); | 4065 GenerateLookupNumberStringCache(masm, ebx, eax, ecx, edx, &runtime); |
| 4073 __ ret(1 * kPointerSize); | 4066 __ ret(1 * kPointerSize); |
| 4074 | 4067 |
| 4075 __ bind(&runtime); | 4068 __ bind(&runtime); |
| 4076 // Handle number to string in the runtime system if not found in the cache. | 4069 // Handle number to string in the runtime system if not found in the cache. |
| 4077 __ TailCallRuntime(Runtime::kNumberToStringSkipCache, 1, 1); | 4070 __ TailCallRuntime(Runtime::kNumberToStringSkipCache, 1, 1); |
| 4078 } | 4071 } |
| 4079 | 4072 |
| 4080 | 4073 |
| 4081 static int NegativeComparisonResult(Condition cc) { | 4074 static int NegativeComparisonResult(Condition cc) { |
| 4082 ASSERT(cc != equal); | 4075 ASSERT(cc != equal); |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5752 | 5745 |
| 5753 // Check the number to string cache. | 5746 // Check the number to string cache. |
| 5754 Label not_cached; | 5747 Label not_cached; |
| 5755 __ bind(¬_string); | 5748 __ bind(¬_string); |
| 5756 // Puts the cached result into scratch1. | 5749 // Puts the cached result into scratch1. |
| 5757 NumberToStringStub::GenerateLookupNumberStringCache(masm, | 5750 NumberToStringStub::GenerateLookupNumberStringCache(masm, |
| 5758 arg, | 5751 arg, |
| 5759 scratch1, | 5752 scratch1, |
| 5760 scratch2, | 5753 scratch2, |
| 5761 scratch3, | 5754 scratch3, |
| 5762 false, | |
| 5763 ¬_cached); | 5755 ¬_cached); |
| 5764 __ mov(arg, scratch1); | 5756 __ mov(arg, scratch1); |
| 5765 __ mov(Operand(esp, stack_offset), arg); | 5757 __ mov(Operand(esp, stack_offset), arg); |
| 5766 __ jmp(&done); | 5758 __ jmp(&done); |
| 5767 | 5759 |
| 5768 // Check if the argument is a safe string wrapper. | 5760 // Check if the argument is a safe string wrapper. |
| 5769 __ bind(¬_cached); | 5761 __ bind(¬_cached); |
| 5770 __ JumpIfSmi(arg, slow); | 5762 __ JumpIfSmi(arg, slow); |
| 5771 __ CmpObjectType(arg, JS_VALUE_TYPE, scratch1); // map -> scratch1. | 5763 __ CmpObjectType(arg, JS_VALUE_TYPE, scratch1); // map -> scratch1. |
| 5772 __ j(not_equal, slow); | 5764 __ j(not_equal, slow); |
| (...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7781 __ bind(&fast_elements_case); | 7773 __ bind(&fast_elements_case); |
| 7782 GenerateCase(masm, FAST_ELEMENTS); | 7774 GenerateCase(masm, FAST_ELEMENTS); |
| 7783 } | 7775 } |
| 7784 | 7776 |
| 7785 | 7777 |
| 7786 #undef __ | 7778 #undef __ |
| 7787 | 7779 |
| 7788 } } // namespace v8::internal | 7780 } } // namespace v8::internal |
| 7789 | 7781 |
| 7790 #endif // V8_TARGET_ARCH_IA32 | 7782 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |