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

Side by Side Diff: src/arm/codegen-arm.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/arm/builtins-arm.cc ('k') | src/arm/deoptimizer-arm.cc » ('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_ARM 7 #if V8_TARGET_ARCH_ARM
8 8
9 #include "codegen.h" 9 #include "codegen.h"
10 #include "macro-assembler.h" 10 #include "macro-assembler.h"
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 __ bind(&done); 815 __ bind(&done);
816 } 816 }
817 817
818 #undef __ 818 #undef __
819 819
820 #ifdef DEBUG 820 #ifdef DEBUG
821 // add(r0, pc, Operand(-8)) 821 // add(r0, pc, Operand(-8))
822 static const uint32_t kCodeAgePatchFirstInstruction = 0xe24f0008; 822 static const uint32_t kCodeAgePatchFirstInstruction = 0xe24f0008;
823 #endif 823 #endif
824 824
825 static byte* GetNoCodeAgeSequence(uint32_t* length) { 825 CodeAgingHelper::CodeAgingHelper() {
826 // The sequence of instructions that is patched out for aging code is the 826 ASSERT(young_sequence_.length() == kNoCodeAgeSequenceLength);
827 // following boilerplate stack-building prologue that is found in FUNCTIONS 827 // Since patcher is a large object, allocate it dynamically when needed,
828 static bool initialized = false; 828 // to avoid overloading the stack in stress conditions.
829 static uint32_t sequence[kNoCodeAgeSequenceLength]; 829 // DONT_FLUSH is used because the CodeAgingHelper is initialized early in
830 byte* byte_sequence = reinterpret_cast<byte*>(sequence); 830 // the process, before ARM simulator ICache is setup.
831 *length = kNoCodeAgeSequenceLength * Assembler::kInstrSize; 831 SmartPointer<CodePatcher> patcher(
832 if (!initialized) { 832 new CodePatcher(young_sequence_.start(),
833 // Since patcher is a large object, allocate it dynamically when needed, 833 young_sequence_.length() / Assembler::kInstrSize,
834 // to avoid overloading the stack in stress conditions. 834 CodePatcher::DONT_FLUSH));
835 SmartPointer<CodePatcher> 835 PredictableCodeSizeScope scope(patcher->masm(), young_sequence_.length());
836 patcher(new CodePatcher(byte_sequence, kNoCodeAgeSequenceLength)); 836 patcher->masm()->PushFixedFrame(r1);
837 PredictableCodeSizeScope scope(patcher->masm(), *length); 837 patcher->masm()->nop(ip.code());
838 patcher->masm()->PushFixedFrame(r1); 838 patcher->masm()->add(
839 patcher->masm()->nop(ip.code()); 839 fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
840 patcher->masm()->add(
841 fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
842 initialized = true;
843 }
844 return byte_sequence;
845 } 840 }
846 841
847 842
848 bool Code::IsYoungSequence(byte* sequence) { 843 #ifdef DEBUG
849 uint32_t young_length; 844 bool CodeAgingHelper::IsOld(byte* candidate) const {
850 byte* young_sequence = GetNoCodeAgeSequence(&young_length); 845 return Memory::uint32_at(candidate) == kCodeAgePatchFirstInstruction;
851 bool result = !memcmp(sequence, young_sequence, young_length); 846 }
852 ASSERT(result || 847 #endif
853 Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction); 848
849
850 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) {
851 bool result = isolate->code_aging_helper()->IsYoung(sequence);
852 ASSERT(result || isolate->code_aging_helper()->IsOld(sequence));
854 return result; 853 return result;
855 } 854 }
856 855
857 856
858 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, 857 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age,
859 MarkingParity* parity) { 858 MarkingParity* parity) {
860 if (IsYoungSequence(sequence)) { 859 if (IsYoungSequence(isolate, sequence)) {
861 *age = kNoAgeCodeAge; 860 *age = kNoAgeCodeAge;
862 *parity = NO_MARKING_PARITY; 861 *parity = NO_MARKING_PARITY;
863 } else { 862 } else {
864 Address target_address = Memory::Address_at( 863 Address target_address = Memory::Address_at(
865 sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1)); 864 sequence + (kNoCodeAgeSequenceLength - Assembler::kInstrSize));
866 Code* stub = GetCodeFromTargetAddress(target_address); 865 Code* stub = GetCodeFromTargetAddress(target_address);
867 GetCodeAgeAndParity(stub, age, parity); 866 GetCodeAgeAndParity(stub, age, parity);
868 } 867 }
869 } 868 }
870 869
871 870
872 void Code::PatchPlatformCodeAge(Isolate* isolate, 871 void Code::PatchPlatformCodeAge(Isolate* isolate,
873 byte* sequence, 872 byte* sequence,
874 Code::Age age, 873 Code::Age age,
875 MarkingParity parity) { 874 MarkingParity parity) {
876 uint32_t young_length; 875 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length();
877 byte* young_sequence = GetNoCodeAgeSequence(&young_length);
878 if (age == kNoAgeCodeAge) { 876 if (age == kNoAgeCodeAge) {
879 CopyBytes(sequence, young_sequence, young_length); 877 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence);
880 CPU::FlushICache(sequence, young_length); 878 CPU::FlushICache(sequence, young_length);
881 } else { 879 } else {
882 Code* stub = GetCodeAgeStub(isolate, age, parity); 880 Code* stub = GetCodeAgeStub(isolate, age, parity);
883 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); 881 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize);
884 patcher.masm()->add(r0, pc, Operand(-8)); 882 patcher.masm()->add(r0, pc, Operand(-8));
885 patcher.masm()->ldr(pc, MemOperand(pc, -4)); 883 patcher.masm()->ldr(pc, MemOperand(pc, -4));
886 patcher.masm()->emit_code_stub_address(stub); 884 patcher.masm()->emit_code_stub_address(stub);
887 } 885 }
888 } 886 }
889 887
890 888
891 } } // namespace v8::internal 889 } } // namespace v8::internal
892 890
893 #endif // V8_TARGET_ARCH_ARM 891 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/deoptimizer-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698