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 3192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 int token_offset = | 3203 int token_offset = |
3204 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; | 3204 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; |
3205 movq(scratch, FieldOperand(scratch, token_offset)); | 3205 movq(scratch, FieldOperand(scratch, token_offset)); |
3206 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); | 3206 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); |
3207 j(not_equal, miss); | 3207 j(not_equal, miss); |
3208 | 3208 |
3209 bind(&same_contexts); | 3209 bind(&same_contexts); |
3210 } | 3210 } |
3211 | 3211 |
3212 | 3212 |
| 3213 void MacroAssembler::GetNumberHash(Register r0, Register scratch) { |
| 3214 // First of all we assign the hash seed to scratch. |
| 3215 LoadRoot(scratch, Heap::kHashSeedRootIndex); |
| 3216 SmiToInteger32(scratch, scratch); |
| 3217 |
| 3218 // Xor original key with a seed. |
| 3219 xorl(r0, scratch); |
| 3220 |
| 3221 // Compute the hash code from the untagged key. This must be kept in sync |
| 3222 // with ComputeIntegerHash in utils.h. |
| 3223 // |
| 3224 // hash = ~hash + (hash << 15); |
| 3225 movl(scratch, r0); |
| 3226 notl(r0); |
| 3227 shll(scratch, Immediate(15)); |
| 3228 addl(r0, scratch); |
| 3229 // hash = hash ^ (hash >> 12); |
| 3230 movl(scratch, r0); |
| 3231 shrl(scratch, Immediate(12)); |
| 3232 xorl(r0, scratch); |
| 3233 // hash = hash + (hash << 2); |
| 3234 leal(r0, Operand(r0, r0, times_4, 0)); |
| 3235 // hash = hash ^ (hash >> 4); |
| 3236 movl(scratch, r0); |
| 3237 shrl(scratch, Immediate(4)); |
| 3238 xorl(r0, scratch); |
| 3239 // hash = hash * 2057; |
| 3240 imull(r0, r0, Immediate(2057)); |
| 3241 // hash = hash ^ (hash >> 16); |
| 3242 movl(scratch, r0); |
| 3243 shrl(scratch, Immediate(16)); |
| 3244 xorl(r0, scratch); |
| 3245 } |
| 3246 |
| 3247 |
| 3248 |
3213 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | 3249 void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
3214 Register elements, | 3250 Register elements, |
3215 Register key, | 3251 Register key, |
3216 Register r0, | 3252 Register r0, |
3217 Register r1, | 3253 Register r1, |
3218 Register r2, | 3254 Register r2, |
3219 Register result) { | 3255 Register result) { |
3220 // Register use: | 3256 // Register use: |
3221 // | 3257 // |
3222 // elements - holds the slow-case elements of the receiver on entry. | 3258 // elements - holds the slow-case elements of the receiver on entry. |
(...skipping 10 matching lines...) Expand all Loading... |
3233 // | 3269 // |
3234 // r2 - used for the index into the dictionary. | 3270 // r2 - used for the index into the dictionary. |
3235 // | 3271 // |
3236 // result - holds the result on exit if the load succeeded. | 3272 // result - holds the result on exit if the load succeeded. |
3237 // Allowed to be the same as 'key' or 'result'. | 3273 // Allowed to be the same as 'key' or 'result'. |
3238 // Unchanged on bailout so 'key' or 'result' can be used | 3274 // Unchanged on bailout so 'key' or 'result' can be used |
3239 // in further computation. | 3275 // in further computation. |
3240 | 3276 |
3241 Label done; | 3277 Label done; |
3242 | 3278 |
3243 // Compute the hash code from the untagged key. This must be kept in sync | 3279 GetNumberHash(r0, r1); |
3244 // with ComputeIntegerHash in utils.h. | |
3245 // | |
3246 // hash = ~hash + (hash << 15); | |
3247 movl(r1, r0); | |
3248 notl(r0); | |
3249 shll(r1, Immediate(15)); | |
3250 addl(r0, r1); | |
3251 // hash = hash ^ (hash >> 12); | |
3252 movl(r1, r0); | |
3253 shrl(r1, Immediate(12)); | |
3254 xorl(r0, r1); | |
3255 // hash = hash + (hash << 2); | |
3256 leal(r0, Operand(r0, r0, times_4, 0)); | |
3257 // hash = hash ^ (hash >> 4); | |
3258 movl(r1, r0); | |
3259 shrl(r1, Immediate(4)); | |
3260 xorl(r0, r1); | |
3261 // hash = hash * 2057; | |
3262 imull(r0, r0, Immediate(2057)); | |
3263 // hash = hash ^ (hash >> 16); | |
3264 movl(r1, r0); | |
3265 shrl(r1, Immediate(16)); | |
3266 xorl(r0, r1); | |
3267 | 3280 |
3268 // Compute capacity mask. | 3281 // Compute capacity mask. |
3269 SmiToInteger32(r1, | 3282 SmiToInteger32(r1, FieldOperand(elements, |
3270 FieldOperand(elements, NumberDictionary::kCapacityOffset)); | 3283 SeededNumberDictionary::kCapacityOffset)); |
3271 decl(r1); | 3284 decl(r1); |
3272 | 3285 |
3273 // Generate an unrolled loop that performs a few probes before giving up. | 3286 // Generate an unrolled loop that performs a few probes before giving up. |
3274 const int kProbes = 4; | 3287 const int kProbes = 4; |
3275 for (int i = 0; i < kProbes; i++) { | 3288 for (int i = 0; i < kProbes; i++) { |
3276 // Use r2 for index calculations and keep the hash intact in r0. | 3289 // Use r2 for index calculations and keep the hash intact in r0. |
3277 movq(r2, r0); | 3290 movq(r2, r0); |
3278 // Compute the masked index: (hash + i + i * i) & mask. | 3291 // Compute the masked index: (hash + i + i * i) & mask. |
3279 if (i > 0) { | 3292 if (i > 0) { |
3280 addl(r2, Immediate(NumberDictionary::GetProbeOffset(i))); | 3293 addl(r2, Immediate(SeededNumberDictionary::GetProbeOffset(i))); |
3281 } | 3294 } |
3282 and_(r2, r1); | 3295 and_(r2, r1); |
3283 | 3296 |
3284 // Scale the index by multiplying by the entry size. | 3297 // Scale the index by multiplying by the entry size. |
3285 ASSERT(NumberDictionary::kEntrySize == 3); | 3298 ASSERT(SeededNumberDictionary::kEntrySize == 3); |
3286 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 | 3299 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 |
3287 | 3300 |
3288 // Check if the key matches. | 3301 // Check if the key matches. |
3289 cmpq(key, FieldOperand(elements, | 3302 cmpq(key, FieldOperand(elements, |
3290 r2, | 3303 r2, |
3291 times_pointer_size, | 3304 times_pointer_size, |
3292 NumberDictionary::kElementsStartOffset)); | 3305 SeededNumberDictionary::kElementsStartOffset)); |
3293 if (i != (kProbes - 1)) { | 3306 if (i != (kProbes - 1)) { |
3294 j(equal, &done); | 3307 j(equal, &done); |
3295 } else { | 3308 } else { |
3296 j(not_equal, miss); | 3309 j(not_equal, miss); |
3297 } | 3310 } |
3298 } | 3311 } |
3299 | 3312 |
3300 bind(&done); | 3313 bind(&done); |
3301 // Check that the value is a normal propety. | 3314 // Check that the value is a normal propety. |
3302 const int kDetailsOffset = | 3315 const int kDetailsOffset = |
3303 NumberDictionary::kElementsStartOffset + 2 * kPointerSize; | 3316 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize; |
3304 ASSERT_EQ(NORMAL, 0); | 3317 ASSERT_EQ(NORMAL, 0); |
3305 Test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), | 3318 Test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), |
3306 Smi::FromInt(PropertyDetails::TypeField::kMask)); | 3319 Smi::FromInt(PropertyDetails::TypeField::kMask)); |
3307 j(not_zero, miss); | 3320 j(not_zero, miss); |
3308 | 3321 |
3309 // Get the value at the masked, scaled index. | 3322 // Get the value at the masked, scaled index. |
3310 const int kValueOffset = | 3323 const int kValueOffset = |
3311 NumberDictionary::kElementsStartOffset + kPointerSize; | 3324 SeededNumberDictionary::kElementsStartOffset + kPointerSize; |
3312 movq(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); | 3325 movq(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); |
3313 } | 3326 } |
3314 | 3327 |
3315 | 3328 |
3316 void MacroAssembler::LoadAllocationTopHelper(Register result, | 3329 void MacroAssembler::LoadAllocationTopHelper(Register result, |
3317 Register scratch, | 3330 Register scratch, |
3318 AllocationFlags flags) { | 3331 AllocationFlags flags) { |
3319 ExternalReference new_space_allocation_top = | 3332 ExternalReference new_space_allocation_top = |
3320 ExternalReference::new_space_allocation_top_address(isolate()); | 3333 ExternalReference::new_space_allocation_top_address(isolate()); |
3321 | 3334 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 CPU::FlushICache(address_, size_); | 3901 CPU::FlushICache(address_, size_); |
3889 | 3902 |
3890 // Check that the code was patched as expected. | 3903 // Check that the code was patched as expected. |
3891 ASSERT(masm_.pc_ == address_ + size_); | 3904 ASSERT(masm_.pc_ == address_ + size_); |
3892 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3905 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3893 } | 3906 } |
3894 | 3907 |
3895 } } // namespace v8::internal | 3908 } } // namespace v8::internal |
3896 | 3909 |
3897 #endif // V8_TARGET_ARCH_X64 | 3910 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |