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

Side by Side Diff: src/arm/full-codegen-arm.cc

Issue 24237009: Less aggressive polling when concurrently compiling for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment. added TODO. Created 7 years, 2 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/builtins.h » ('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 // 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 4877 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 *context_length = 0; 4888 *context_length = 0;
4889 return previous_; 4889 return previous_;
4890 } 4890 }
4891 4891
4892 4892
4893 #undef __ 4893 #undef __
4894 4894
4895 4895
4896 static const int32_t kBranchBeforeInterrupt = 0x5a000004; 4896 static const int32_t kBranchBeforeInterrupt = 0x5a000004;
4897 4897
4898 // The back edge bookkeeping code matches the pattern:
4899 //
4900 // <decrement profiling counter>
4901 // 2a 00 00 01 bpl ok
4902 // e5 9f c? ?? ldr ip, [pc, <interrupt stub address>]
4903 // e1 2f ff 3c blx ip
4904 // ok-label
4905 //
4906 // We patch the code to the following form:
4907 //
4908 // <decrement profiling counter>
4909 // e1 a0 00 00 mov r0, r0 (NOP)
4910 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>]
4911 // e1 2f ff 3c blx ip
4912 // ok-label
4913 4898
4914 void BackEdgeTable::PatchAt(Code* unoptimized_code, 4899 void BackEdgeTable::PatchAt(Code* unoptimized_code,
4915 Address pc_after, 4900 Address pc,
4901 BackEdgeState target_state,
4916 Code* replacement_code) { 4902 Code* replacement_code) {
4917 static const int kInstrSize = Assembler::kInstrSize; 4903 static const int kInstrSize = Assembler::kInstrSize;
4918 // Turn the jump into nops. 4904 Address branch_address = pc - 3 * kInstrSize;
4919 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); 4905 CodePatcher patcher(branch_address, 1);
4920 patcher.masm()->nop(); 4906
4907 switch (target_state) {
4908 case INTERRUPT:
4909 // <decrement profiling counter>
4910 // 2a 00 00 01 bpl ok
4911 // e5 9f c? ?? ldr ip, [pc, <interrupt stub address>]
4912 // e1 2f ff 3c blx ip
4913 // ok-label
4914 patcher.masm()->b(4 * kInstrSize, pl); // Jump offset is 4 instructions.
4915 ASSERT_EQ(kBranchBeforeInterrupt, Memory::int32_at(branch_address));
4916 break;
4917 case ON_STACK_REPLACEMENT:
4918 case OSR_AFTER_STACK_CHECK:
4919 // <decrement profiling counter>
4920 // e1 a0 00 00 mov r0, r0 (NOP)
4921 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>]
4922 // e1 2f ff 3c blx ip
4923 // ok-label
4924 patcher.masm()->nop();
4925 break;
4926 }
4927
4928 Address pc_immediate_load_address = pc - 2 * kInstrSize;
4921 // Replace the call address. 4929 // Replace the call address.
4922 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after - 4930 uint32_t interrupt_address_offset =
4923 2 * kInstrSize) & 0xfff; 4931 Memory::uint16_at(pc_immediate_load_address) & 0xfff;
4924 Address interrupt_address_pointer = pc_after + interrupt_address_offset; 4932 Address interrupt_address_pointer = pc + interrupt_address_offset;
4925 Memory::uint32_at(interrupt_address_pointer) = 4933 Memory::uint32_at(interrupt_address_pointer) =
4926 reinterpret_cast<uint32_t>(replacement_code->entry()); 4934 reinterpret_cast<uint32_t>(replacement_code->entry());
4927 4935
4928 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 4936 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
4929 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); 4937 unoptimized_code, pc_immediate_load_address, replacement_code);
4930 } 4938 }
4931 4939
4932 4940
4933 void BackEdgeTable::RevertAt(Code* unoptimized_code, 4941 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState(
4934 Address pc_after, 4942 Isolate* isolate,
4935 Code* interrupt_code) { 4943 Code* unoptimized_code,
4944 Address pc) {
4936 static const int kInstrSize = Assembler::kInstrSize; 4945 static const int kInstrSize = Assembler::kInstrSize;
4937 // Restore the original jump. 4946 ASSERT(Memory::int32_at(pc - kInstrSize) == kBlxIp);
4938 CodePatcher patcher(pc_after - 3 * kInstrSize, 1);
4939 patcher.masm()->b(4 * kInstrSize, pl); // ok-label is 4 instructions later.
4940 ASSERT_EQ(kBranchBeforeInterrupt,
4941 Memory::int32_at(pc_after - 3 * kInstrSize));
4942 // Restore the original call address.
4943 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after -
4944 2 * kInstrSize) & 0xfff;
4945 Address interrupt_address_pointer = pc_after + interrupt_address_offset;
4946 Memory::uint32_at(interrupt_address_pointer) =
4947 reinterpret_cast<uint32_t>(interrupt_code->entry());
4948 4947
4949 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 4948 Address branch_address = pc - 3 * kInstrSize;
4950 unoptimized_code, pc_after - 2 * kInstrSize, interrupt_code); 4949 Address pc_immediate_load_address = pc - 2 * kInstrSize;
4950 uint32_t interrupt_address_offset =
4951 Memory::uint16_at(pc_immediate_load_address) & 0xfff;
4952 Address interrupt_address_pointer = pc + interrupt_address_offset;
4953
4954 if (Memory::int32_at(branch_address) == kBranchBeforeInterrupt) {
4955 ASSERT(Memory::uint32_at(interrupt_address_pointer) ==
4956 reinterpret_cast<uint32_t>(
4957 isolate->builtins()->InterruptCheck()->entry()));
4958 ASSERT(Assembler::IsLdrPcImmediateOffset(
4959 Assembler::instr_at(pc_immediate_load_address)));
4960 return INTERRUPT;
4961 }
4962
4963 ASSERT(Assembler::IsNop(Assembler::instr_at(branch_address)));
4964 ASSERT(Assembler::IsLdrPcImmediateOffset(
4965 Assembler::instr_at(pc_immediate_load_address)));
4966
4967 if (Memory::uint32_at(interrupt_address_pointer) ==
4968 reinterpret_cast<uint32_t>(
4969 isolate->builtins()->OnStackReplacement()->entry())) {
4970 return ON_STACK_REPLACEMENT;
4971 }
4972
4973 ASSERT(Memory::uint32_at(interrupt_address_pointer) ==
4974 reinterpret_cast<uint32_t>(
4975 isolate->builtins()->OsrAfterStackCheck()->entry()));
4976 return OSR_AFTER_STACK_CHECK;
4951 } 4977 }
4952 4978
4953 4979
4954 #ifdef DEBUG
4955 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState(
4956 Isolate* isolate,
4957 Code* unoptimized_code,
4958 Address pc_after) {
4959 static const int kInstrSize = Assembler::kInstrSize;
4960 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp);
4961
4962 uint32_t interrupt_address_offset =
4963 Memory::uint16_at(pc_after - 2 * kInstrSize) & 0xfff;
4964 Address interrupt_address_pointer = pc_after + interrupt_address_offset;
4965
4966 if (Assembler::IsNop(Assembler::instr_at(pc_after - 3 * kInstrSize))) {
4967 ASSERT(Assembler::IsLdrPcImmediateOffset(
4968 Assembler::instr_at(pc_after - 2 * kInstrSize)));
4969 Code* osr_builtin =
4970 isolate->builtins()->builtin(Builtins::kOnStackReplacement);
4971 ASSERT(reinterpret_cast<uint32_t>(osr_builtin->entry()) ==
4972 Memory::uint32_at(interrupt_address_pointer));
4973 return ON_STACK_REPLACEMENT;
4974 } else {
4975 // Get the interrupt stub code object to match against from cache.
4976 Code* interrupt_builtin =
4977 isolate->builtins()->builtin(Builtins::kInterruptCheck);
4978 ASSERT(Assembler::IsLdrPcImmediateOffset(
4979 Assembler::instr_at(pc_after - 2 * kInstrSize)));
4980 ASSERT_EQ(kBranchBeforeInterrupt,
4981 Memory::int32_at(pc_after - 3 * kInstrSize));
4982 ASSERT(reinterpret_cast<uint32_t>(interrupt_builtin->entry()) ==
4983 Memory::uint32_at(interrupt_address_pointer));
4984 return INTERRUPT;
4985 }
4986 }
4987 #endif // DEBUG
4988
4989
4990 } } // namespace v8::internal 4980 } } // namespace v8::internal
4991 4981
4992 #endif // V8_TARGET_ARCH_ARM 4982 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698