Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 23618056: Move NumberToStringStub::GenerateLookupNumberStringCache to the MacroAssembler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 Register scratch, 3016 Register scratch,
3017 int power) { 3017 int power) {
3018 ASSERT(is_uintn(power + HeapNumber::kExponentBias, 3018 ASSERT(is_uintn(power + HeapNumber::kExponentBias,
3019 HeapNumber::kExponentBits)); 3019 HeapNumber::kExponentBits));
3020 mov(scratch, Immediate(power + HeapNumber::kExponentBias)); 3020 mov(scratch, Immediate(power + HeapNumber::kExponentBias));
3021 movd(dst, scratch); 3021 movd(dst, scratch);
3022 psllq(dst, HeapNumber::kMantissaBits); 3022 psllq(dst, HeapNumber::kMantissaBits);
3023 } 3023 }
3024 3024
3025 3025
3026 void MacroAssembler::LookupNumberStringCache(Register object,
3027 Register result,
3028 Register scratch1,
3029 Register scratch2,
3030 Label* not_found) {
3031 // Use of registers. Register result is used as a temporary.
3032 Register number_string_cache = result;
3033 Register mask = scratch1;
3034 Register scratch = scratch2;
3035
3036 // Load the number string cache.
3037 LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
3038 // Make the hash mask from the length of the number string cache. It
3039 // contains two elements (number and string) for each cache entry.
3040 mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset));
3041 shr(mask, kSmiTagSize + 1); // Untag length and divide it by two.
3042 sub(mask, Immediate(1)); // Make mask.
3043
3044 // Calculate the entry in the number string cache. The hash value in the
3045 // number string cache for smis is just the smi value, and the hash for
3046 // doubles is the xor of the upper and lower words. See
3047 // Heap::GetNumberStringCache.
3048 Label smi_hash_calculated;
3049 Label load_result_from_cache;
3050 Label not_smi;
3051 STATIC_ASSERT(kSmiTag == 0);
3052 JumpIfNotSmi(object, &not_smi, Label::kNear);
3053 mov(scratch, object);
3054 SmiUntag(scratch);
3055 jmp(&smi_hash_calculated, Label::kNear);
3056 bind(&not_smi);
3057 cmp(FieldOperand(object, HeapObject::kMapOffset),
3058 isolate()->factory()->heap_number_map());
3059 j(not_equal, not_found);
3060 STATIC_ASSERT(8 == kDoubleSize);
3061 mov(scratch, FieldOperand(object, HeapNumber::kValueOffset));
3062 xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4));
3063 // Object is heap number and hash is now in scratch. Calculate cache index.
3064 and_(scratch, mask);
3065 Register index = scratch;
3066 Register probe = mask;
3067 mov(probe,
3068 FieldOperand(number_string_cache,
3069 index,
3070 times_twice_pointer_size,
3071 FixedArray::kHeaderSize));
3072 JumpIfSmi(probe, not_found);
3073 if (CpuFeatures::IsSupported(SSE2)) {
3074 CpuFeatureScope fscope(this, SSE2);
3075 movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset));
3076 ucomisd(xmm0, FieldOperand(probe, HeapNumber::kValueOffset));
3077 } else {
3078 fld_d(FieldOperand(object, HeapNumber::kValueOffset));
3079 fld_d(FieldOperand(probe, HeapNumber::kValueOffset));
3080 FCmp();
3081 }
3082 j(parity_even, not_found); // Bail out if NaN is involved.
3083 j(not_equal, not_found); // The cache did not contain this value.
3084 jmp(&load_result_from_cache, Label::kNear);
3085
3086 bind(&smi_hash_calculated);
3087 // Object is smi and hash is now in scratch. Calculate cache index.
3088 and_(scratch, mask);
3089 // Check if the entry is the smi we are looking for.
3090 cmp(object,
3091 FieldOperand(number_string_cache,
3092 index,
3093 times_twice_pointer_size,
3094 FixedArray::kHeaderSize));
3095 j(not_equal, not_found);
3096
3097 // Get the result from the cache.
3098 bind(&load_result_from_cache);
3099 mov(result,
3100 FieldOperand(number_string_cache,
3101 index,
3102 times_twice_pointer_size,
3103 FixedArray::kHeaderSize + kPointerSize));
3104 IncrementCounter(isolate()->counters()->number_to_string_native(), 1);
3105 }
3106
3107
3026 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii( 3108 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(
3027 Register instance_type, 3109 Register instance_type,
3028 Register scratch, 3110 Register scratch,
3029 Label* failure) { 3111 Label* failure) {
3030 if (!scratch.is(instance_type)) { 3112 if (!scratch.is(instance_type)) {
3031 mov(scratch, instance_type); 3113 mov(scratch, instance_type);
3032 } 3114 }
3033 and_(scratch, 3115 and_(scratch,
3034 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); 3116 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask);
3035 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag); 3117 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 j(greater, &no_memento_available); 3526 j(greater, &no_memento_available);
3445 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), 3527 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize),
3446 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 3528 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map())));
3447 bind(&no_memento_available); 3529 bind(&no_memento_available);
3448 } 3530 }
3449 3531
3450 3532
3451 } } // namespace v8::internal 3533 } } // namespace v8::internal
3452 3534
3453 #endif // V8_TARGET_ARCH_IA32 3535 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698