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

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

Issue 1336133003: X87: [builtins] Simplify String constructor code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/x87/macro-assembler-x87.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 AccessorComponent accessor) { 2463 AccessorComponent accessor) {
2464 mov(dst, FieldOperand(holder, HeapObject::kMapOffset)); 2464 mov(dst, FieldOperand(holder, HeapObject::kMapOffset));
2465 LoadInstanceDescriptors(dst, dst); 2465 LoadInstanceDescriptors(dst, dst);
2466 mov(dst, FieldOperand(dst, DescriptorArray::GetValueOffset(accessor_index))); 2466 mov(dst, FieldOperand(dst, DescriptorArray::GetValueOffset(accessor_index)));
2467 int offset = accessor == ACCESSOR_GETTER ? AccessorPair::kGetterOffset 2467 int offset = accessor == ACCESSOR_GETTER ? AccessorPair::kGetterOffset
2468 : AccessorPair::kSetterOffset; 2468 : AccessorPair::kSetterOffset;
2469 mov(dst, FieldOperand(dst, offset)); 2469 mov(dst, FieldOperand(dst, offset));
2470 } 2470 }
2471 2471
2472 2472
2473 void MacroAssembler::LookupNumberStringCache(Register object,
2474 Register result,
2475 Register scratch1,
2476 Register scratch2,
2477 Label* not_found) {
2478 // Use of registers. Register result is used as a temporary.
2479 Register number_string_cache = result;
2480 Register mask = scratch1;
2481 Register scratch = scratch2;
2482
2483 // Load the number string cache.
2484 LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
2485 // Make the hash mask from the length of the number string cache. It
2486 // contains two elements (number and string) for each cache entry.
2487 mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset));
2488 shr(mask, kSmiTagSize + 1); // Untag length and divide it by two.
2489 sub(mask, Immediate(1)); // Make mask.
2490
2491 // Calculate the entry in the number string cache. The hash value in the
2492 // number string cache for smis is just the smi value, and the hash for
2493 // doubles is the xor of the upper and lower words. See
2494 // Heap::GetNumberStringCache.
2495 Label smi_hash_calculated;
2496 Label load_result_from_cache;
2497 Label not_smi;
2498 STATIC_ASSERT(kSmiTag == 0);
2499 JumpIfNotSmi(object, &not_smi, Label::kNear);
2500 mov(scratch, object);
2501 SmiUntag(scratch);
2502 jmp(&smi_hash_calculated, Label::kNear);
2503 bind(&not_smi);
2504 cmp(FieldOperand(object, HeapObject::kMapOffset),
2505 isolate()->factory()->heap_number_map());
2506 j(not_equal, not_found);
2507 STATIC_ASSERT(8 == kDoubleSize);
2508 mov(scratch, FieldOperand(object, HeapNumber::kValueOffset));
2509 xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4));
2510 // Object is heap number and hash is now in scratch. Calculate cache index.
2511 and_(scratch, mask);
2512 Register index = scratch;
2513 Register probe = mask;
2514 mov(probe,
2515 FieldOperand(number_string_cache,
2516 index,
2517 times_twice_pointer_size,
2518 FixedArray::kHeaderSize));
2519 JumpIfSmi(probe, not_found);
2520 fld_d(FieldOperand(object, HeapNumber::kValueOffset));
2521 fld_d(FieldOperand(probe, HeapNumber::kValueOffset));
2522 FCmp();
2523 j(parity_even, not_found); // Bail out if NaN is involved.
2524 j(not_equal, not_found); // The cache did not contain this value.
2525 jmp(&load_result_from_cache, Label::kNear);
2526
2527 bind(&smi_hash_calculated);
2528 // Object is smi and hash is now in scratch. Calculate cache index.
2529 and_(scratch, mask);
2530 // Check if the entry is the smi we are looking for.
2531 cmp(object,
2532 FieldOperand(number_string_cache,
2533 index,
2534 times_twice_pointer_size,
2535 FixedArray::kHeaderSize));
2536 j(not_equal, not_found);
2537
2538 // Get the result from the cache.
2539 bind(&load_result_from_cache);
2540 mov(result,
2541 FieldOperand(number_string_cache,
2542 index,
2543 times_twice_pointer_size,
2544 FixedArray::kHeaderSize + kPointerSize));
2545 IncrementCounter(isolate()->counters()->number_to_string_native(), 1);
2546 }
2547
2548
2549 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte( 2473 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(
2550 Register instance_type, Register scratch, Label* failure) { 2474 Register instance_type, Register scratch, Label* failure) {
2551 if (!scratch.is(instance_type)) { 2475 if (!scratch.is(instance_type)) {
2552 mov(scratch, instance_type); 2476 mov(scratch, instance_type);
2553 } 2477 }
2554 and_(scratch, 2478 and_(scratch,
2555 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); 2479 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask);
2556 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag); 2480 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag);
2557 j(not_equal, failure); 2481 j(not_equal, failure);
2558 } 2482 }
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 mov(eax, dividend); 2990 mov(eax, dividend);
3067 shr(eax, 31); 2991 shr(eax, 31);
3068 add(edx, eax); 2992 add(edx, eax);
3069 } 2993 }
3070 2994
3071 2995
3072 } // namespace internal 2996 } // namespace internal
3073 } // namespace v8 2997 } // namespace v8
3074 2998
3075 #endif // V8_TARGET_ARCH_X87 2999 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/macro-assembler-x87.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698