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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 261953002: Fix for 3303 MultithreadedParallelIsolates has a race condition. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed ICache arm simulator issue. Created 6 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/objects-debug.cc ('k') | test/cctest/cctest.status » ('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 // 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 #include "v8.h" 5 #include "v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "codegen.h" 9 #include "codegen.h"
10 #include "macro-assembler.h" 10 #include "macro-assembler.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 __ subsd(result, double_scratch); 609 __ subsd(result, double_scratch);
610 __ addsd(result, Operand(kScratchRegister, 8 * kDoubleSize)); 610 __ addsd(result, Operand(kScratchRegister, 8 * kDoubleSize));
611 __ mulsd(result, input); 611 __ mulsd(result, input);
612 612
613 __ bind(&done); 613 __ bind(&done);
614 } 614 }
615 615
616 #undef __ 616 #undef __
617 617
618 618
619 static byte* GetNoCodeAgeSequence(uint32_t* length) { 619 CodeAgingHelper::CodeAgingHelper() {
620 static bool initialized = false; 620 ASSERT(young_sequence_.length() == kNoCodeAgeSequenceLength);
621 static byte sequence[kNoCodeAgeSequenceLength]; 621 // The sequence of instructions that is patched out for aging code is the
622 *length = kNoCodeAgeSequenceLength; 622 // following boilerplate stack-building prologue that is found both in
623 if (!initialized) { 623 // FUNCTION and OPTIMIZED_FUNCTION code:
624 // The sequence of instructions that is patched out for aging code is the 624 CodePatcher patcher(young_sequence_.start(), young_sequence_.length());
625 // following boilerplate stack-building prologue that is found both in 625 patcher.masm()->pushq(rbp);
626 // FUNCTION and OPTIMIZED_FUNCTION code: 626 patcher.masm()->movp(rbp, rsp);
627 CodePatcher patcher(sequence, kNoCodeAgeSequenceLength); 627 patcher.masm()->Push(rsi);
628 patcher.masm()->pushq(rbp); 628 patcher.masm()->Push(rdi);
629 patcher.masm()->movp(rbp, rsp);
630 patcher.masm()->Push(rsi);
631 patcher.masm()->Push(rdi);
632 initialized = true;
633 }
634 return sequence;
635 } 629 }
636 630
637 631
638 bool Code::IsYoungSequence(byte* sequence) { 632 #ifdef DEBUG
639 uint32_t young_length; 633 bool CodeAgingHelper::IsOld(byte* candidate) const {
640 byte* young_sequence = GetNoCodeAgeSequence(&young_length); 634 return *candidate == kCallOpcode;
641 bool result = (!memcmp(sequence, young_sequence, young_length)); 635 }
642 ASSERT(result || *sequence == kCallOpcode); 636 #endif
637
638
639 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) {
640 bool result = isolate->code_aging_helper()->IsYoung(sequence);
641 ASSERT(result || isolate->code_aging_helper()->IsOld(sequence));
643 return result; 642 return result;
644 } 643 }
645 644
646 645
647 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, 646 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age,
648 MarkingParity* parity) { 647 MarkingParity* parity) {
649 if (IsYoungSequence(sequence)) { 648 if (IsYoungSequence(isolate, sequence)) {
650 *age = kNoAgeCodeAge; 649 *age = kNoAgeCodeAge;
651 *parity = NO_MARKING_PARITY; 650 *parity = NO_MARKING_PARITY;
652 } else { 651 } else {
653 sequence++; // Skip the kCallOpcode byte 652 sequence++; // Skip the kCallOpcode byte
654 Address target_address = sequence + *reinterpret_cast<int*>(sequence) + 653 Address target_address = sequence + *reinterpret_cast<int*>(sequence) +
655 Assembler::kCallTargetAddressOffset; 654 Assembler::kCallTargetAddressOffset;
656 Code* stub = GetCodeFromTargetAddress(target_address); 655 Code* stub = GetCodeFromTargetAddress(target_address);
657 GetCodeAgeAndParity(stub, age, parity); 656 GetCodeAgeAndParity(stub, age, parity);
658 } 657 }
659 } 658 }
660 659
661 660
662 void Code::PatchPlatformCodeAge(Isolate* isolate, 661 void Code::PatchPlatformCodeAge(Isolate* isolate,
663 byte* sequence, 662 byte* sequence,
664 Code::Age age, 663 Code::Age age,
665 MarkingParity parity) { 664 MarkingParity parity) {
666 uint32_t young_length; 665 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length();
667 byte* young_sequence = GetNoCodeAgeSequence(&young_length);
668 if (age == kNoAgeCodeAge) { 666 if (age == kNoAgeCodeAge) {
669 CopyBytes(sequence, young_sequence, young_length); 667 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence);
670 CPU::FlushICache(sequence, young_length); 668 CPU::FlushICache(sequence, young_length);
671 } else { 669 } else {
672 Code* stub = GetCodeAgeStub(isolate, age, parity); 670 Code* stub = GetCodeAgeStub(isolate, age, parity);
673 CodePatcher patcher(sequence, young_length); 671 CodePatcher patcher(sequence, young_length);
674 patcher.masm()->call(stub->instruction_start()); 672 patcher.masm()->call(stub->instruction_start());
675 patcher.masm()->Nop( 673 patcher.masm()->Nop(
676 kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength); 674 kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength);
677 } 675 }
678 } 676 }
679 677
(...skipping 15 matching lines...) Expand all
695 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize. 693 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize.
696 return Operand(base_reg_, argument_count_reg_, times_pointer_size, 694 return Operand(base_reg_, argument_count_reg_, times_pointer_size,
697 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); 695 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize);
698 } 696 }
699 } 697 }
700 698
701 699
702 } } // namespace v8::internal 700 } } // namespace v8::internal
703 701
704 #endif // V8_TARGET_ARCH_X64 702 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698