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 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3197 int token_offset = | 3197 int token_offset = |
3198 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; | 3198 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; |
3199 movq(scratch, FieldOperand(scratch, token_offset)); | 3199 movq(scratch, FieldOperand(scratch, token_offset)); |
3200 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); | 3200 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); |
3201 j(not_equal, miss); | 3201 j(not_equal, miss); |
3202 | 3202 |
3203 bind(&same_contexts); | 3203 bind(&same_contexts); |
3204 } | 3204 } |
3205 | 3205 |
3206 | 3206 |
| 3207 void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
| 3208 Register elements, |
| 3209 Register key, |
| 3210 Register r0, |
| 3211 Register r1, |
| 3212 Register r2, |
| 3213 Register result) { |
| 3214 // Register use: |
| 3215 // |
| 3216 // elements - holds the slow-case elements of the receiver on entry. |
| 3217 // Unchanged unless 'result' is the same register. |
| 3218 // |
| 3219 // key - holds the smi key on entry. |
| 3220 // Unchanged unless 'result' is the same register. |
| 3221 // |
| 3222 // Scratch registers: |
| 3223 // |
| 3224 // r0 - holds the untagged key on entry and holds the hash once computed. |
| 3225 // |
| 3226 // r1 - used to hold the capacity mask of the dictionary |
| 3227 // |
| 3228 // r2 - used for the index into the dictionary. |
| 3229 // |
| 3230 // result - holds the result on exit if the load succeeded. |
| 3231 // Allowed to be the same as 'key' or 'result'. |
| 3232 // Unchanged on bailout so 'key' or 'result' can be used |
| 3233 // in further computation. |
| 3234 |
| 3235 Label done; |
| 3236 |
| 3237 // Compute the hash code from the untagged key. This must be kept in sync |
| 3238 // with ComputeIntegerHash in utils.h. |
| 3239 // |
| 3240 // hash = ~hash + (hash << 15); |
| 3241 movl(r1, r0); |
| 3242 notl(r0); |
| 3243 shll(r1, Immediate(15)); |
| 3244 addl(r0, r1); |
| 3245 // hash = hash ^ (hash >> 12); |
| 3246 movl(r1, r0); |
| 3247 shrl(r1, Immediate(12)); |
| 3248 xorl(r0, r1); |
| 3249 // hash = hash + (hash << 2); |
| 3250 leal(r0, Operand(r0, r0, times_4, 0)); |
| 3251 // hash = hash ^ (hash >> 4); |
| 3252 movl(r1, r0); |
| 3253 shrl(r1, Immediate(4)); |
| 3254 xorl(r0, r1); |
| 3255 // hash = hash * 2057; |
| 3256 imull(r0, r0, Immediate(2057)); |
| 3257 // hash = hash ^ (hash >> 16); |
| 3258 movl(r1, r0); |
| 3259 shrl(r1, Immediate(16)); |
| 3260 xorl(r0, r1); |
| 3261 |
| 3262 // Compute capacity mask. |
| 3263 SmiToInteger32(r1, |
| 3264 FieldOperand(elements, NumberDictionary::kCapacityOffset)); |
| 3265 decl(r1); |
| 3266 |
| 3267 // Generate an unrolled loop that performs a few probes before giving up. |
| 3268 const int kProbes = 4; |
| 3269 for (int i = 0; i < kProbes; i++) { |
| 3270 // Use r2 for index calculations and keep the hash intact in r0. |
| 3271 movq(r2, r0); |
| 3272 // Compute the masked index: (hash + i + i * i) & mask. |
| 3273 if (i > 0) { |
| 3274 addl(r2, Immediate(NumberDictionary::GetProbeOffset(i))); |
| 3275 } |
| 3276 and_(r2, r1); |
| 3277 |
| 3278 // Scale the index by multiplying by the entry size. |
| 3279 ASSERT(NumberDictionary::kEntrySize == 3); |
| 3280 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 |
| 3281 |
| 3282 // Check if the key matches. |
| 3283 cmpq(key, FieldOperand(elements, |
| 3284 r2, |
| 3285 times_pointer_size, |
| 3286 NumberDictionary::kElementsStartOffset)); |
| 3287 if (i != (kProbes - 1)) { |
| 3288 j(equal, &done); |
| 3289 } else { |
| 3290 j(not_equal, miss); |
| 3291 } |
| 3292 } |
| 3293 |
| 3294 bind(&done); |
| 3295 // Check that the value is a normal propety. |
| 3296 const int kDetailsOffset = |
| 3297 NumberDictionary::kElementsStartOffset + 2 * kPointerSize; |
| 3298 ASSERT_EQ(NORMAL, 0); |
| 3299 Test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), |
| 3300 Smi::FromInt(PropertyDetails::TypeField::mask())); |
| 3301 j(not_zero, miss); |
| 3302 |
| 3303 // Get the value at the masked, scaled index. |
| 3304 const int kValueOffset = |
| 3305 NumberDictionary::kElementsStartOffset + kPointerSize; |
| 3306 movq(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); |
| 3307 } |
| 3308 |
| 3309 |
3207 void MacroAssembler::LoadAllocationTopHelper(Register result, | 3310 void MacroAssembler::LoadAllocationTopHelper(Register result, |
3208 Register scratch, | 3311 Register scratch, |
3209 AllocationFlags flags) { | 3312 AllocationFlags flags) { |
3210 ExternalReference new_space_allocation_top = | 3313 ExternalReference new_space_allocation_top = |
3211 ExternalReference::new_space_allocation_top_address(isolate()); | 3314 ExternalReference::new_space_allocation_top_address(isolate()); |
3212 | 3315 |
3213 // Just return if allocation top is already known. | 3316 // Just return if allocation top is already known. |
3214 if ((flags & RESULT_CONTAINS_TOP) != 0) { | 3317 if ((flags & RESULT_CONTAINS_TOP) != 0) { |
3215 // No use of scratch if allocation top is provided. | 3318 // No use of scratch if allocation top is provided. |
3216 ASSERT(!scratch.is_valid()); | 3319 ASSERT(!scratch.is_valid()); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3743 CPU::FlushICache(address_, size_); | 3846 CPU::FlushICache(address_, size_); |
3744 | 3847 |
3745 // Check that the code was patched as expected. | 3848 // Check that the code was patched as expected. |
3746 ASSERT(masm_.pc_ == address_ + size_); | 3849 ASSERT(masm_.pc_ == address_ + size_); |
3747 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3850 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3748 } | 3851 } |
3749 | 3852 |
3750 } } // namespace v8::internal | 3853 } } // namespace v8::internal |
3751 | 3854 |
3752 #endif // V8_TARGET_ARCH_X64 | 3855 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |