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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 6901150: Fix unary sub IC heap number code on x64: an untagged double was pushed on the stack and GCd. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo on ia32. Created 9 years, 7 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/code-stubs-ia32.cc ('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 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 528 }
529 529
530 530
531 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, 531 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm,
532 Label* slow) { 532 Label* slow) {
533 // Check if the operand is a heap number. 533 // Check if the operand is a heap number.
534 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), 534 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
535 Heap::kHeapNumberMapRootIndex); 535 Heap::kHeapNumberMapRootIndex);
536 __ j(not_equal, slow); 536 __ j(not_equal, slow);
537 537
538 // Operand is a float, negate its value by flipping sign bit. 538 // Operand is a float, negate its value by flipping the sign bit.
539 __ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset));
540 __ Set(kScratchRegister, 0x01);
541 __ shl(kScratchRegister, Immediate(63));
542 __ xor_(rdx, kScratchRegister); // Flip sign.
543 // rdx is value to store.
544 if (mode_ == UNARY_OVERWRITE) { 539 if (mode_ == UNARY_OVERWRITE) {
545 __ movq(FieldOperand(rax, HeapNumber::kValueOffset), rdx); 540 __ Set(kScratchRegister, 0x01);
541 __ shl(kScratchRegister, Immediate(63));
542 __ xor_(FieldOperand(rax, HeapNumber::kValueOffset), kScratchRegister);
546 } else { 543 } else {
544 // Allocate a heap number before calculating the answer,
545 // so we don't have an untagged double around during GC.
547 Label slow_allocate_heapnumber, heapnumber_allocated; 546 Label slow_allocate_heapnumber, heapnumber_allocated;
548 __ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber); 547 __ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber);
549 __ jmp(&heapnumber_allocated); 548 __ jmp(&heapnumber_allocated);
550 549
551 __ bind(&slow_allocate_heapnumber); 550 __ bind(&slow_allocate_heapnumber);
552 __ EnterInternalFrame(); 551 __ EnterInternalFrame();
553 __ push(rdx); 552 __ push(rax);
554 __ CallRuntime(Runtime::kNumberAlloc, 0); 553 __ CallRuntime(Runtime::kNumberAlloc, 0);
555 __ movq(rcx, rax); 554 __ movq(rcx, rax);
556 __ pop(rdx); 555 __ pop(rax);
557 __ LeaveInternalFrame(); 556 __ LeaveInternalFrame();
558
559 __ bind(&heapnumber_allocated); 557 __ bind(&heapnumber_allocated);
560 // rcx: allocated 'empty' number 558 // rcx: allocated 'empty' number
559
560 // Copy the double value to the new heap number, flipping the sign.
561 __ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset));
562 __ Set(kScratchRegister, 0x01);
563 __ shl(kScratchRegister, Immediate(63));
564 __ xor_(rdx, kScratchRegister); // Flip sign.
561 __ movq(FieldOperand(rcx, HeapNumber::kValueOffset), rdx); 565 __ movq(FieldOperand(rcx, HeapNumber::kValueOffset), rdx);
562 __ movq(rax, rcx); 566 __ movq(rax, rcx);
563 } 567 }
564 __ ret(0); 568 __ ret(0);
565 } 569 }
566 570
567 571
568 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeBitNot( 572 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeBitNot(
569 MacroAssembler* masm, 573 MacroAssembler* masm,
570 Label* slow) { 574 Label* slow) {
(...skipping 4159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4730 // Do a tail call to the rewritten stub. 4734 // Do a tail call to the rewritten stub.
4731 __ jmp(rdi); 4735 __ jmp(rdi);
4732 } 4736 }
4733 4737
4734 4738
4735 #undef __ 4739 #undef __
4736 4740
4737 } } // namespace v8::internal 4741 } } // namespace v8::internal
4738 4742
4739 #endif // V8_TARGET_ARCH_X64 4743 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698