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

Side by Side Diff: src/x64/full-codegen-x64.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, 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/builtins-x64.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 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 4866 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 4877
4878 #undef __ 4878 #undef __
4879 4879
4880 4880
4881 static const byte kJnsInstruction = 0x79; 4881 static const byte kJnsInstruction = 0x79;
4882 static const byte kJnsOffset = 0x1d; 4882 static const byte kJnsOffset = 0x1d;
4883 static const byte kCallInstruction = 0xe8; 4883 static const byte kCallInstruction = 0xe8;
4884 static const byte kNopByteOne = 0x66; 4884 static const byte kNopByteOne = 0x66;
4885 static const byte kNopByteTwo = 0x90; 4885 static const byte kNopByteTwo = 0x90;
4886 4886
4887 // The back edge bookkeeping code matches the pattern:
4888 //
4889 // add <profiling_counter>, <-delta>
4890 // jns ok
4891 // call <stack guard>
4892 // ok:
4893 //
4894 // We will patch away the branch so the code is:
4895 //
4896 // add <profiling_counter>, <-delta> ;; Not changed
4897 // nop
4898 // nop
4899 // call <on-stack replacment>
4900 // ok:
4901 4887
4902 void BackEdgeTable::PatchAt(Code* unoptimized_code, 4888 void BackEdgeTable::PatchAt(Code* unoptimized_code,
4903 Address pc_after, 4889 Address pc,
4890 BackEdgeState target_state,
4904 Code* replacement_code) { 4891 Code* replacement_code) {
4905 // Turn the jump into nops. 4892 Address call_target_address = pc - kIntSize;
4906 Address call_target_address = pc_after - kIntSize; 4893 Address jns_instr_address = call_target_address - 3;
4907 *(call_target_address - 3) = kNopByteOne; 4894 Address jns_offset_address = call_target_address - 2;
4908 *(call_target_address - 2) = kNopByteTwo; 4895
4909 // Replace the call address. 4896 switch (target_state) {
4897 case INTERRUPT:
4898 // sub <profiling_counter>, <delta> ;; Not changed
4899 // jns ok
4900 // call <interrupt stub>
4901 // ok:
4902 *jns_instr_address = kJnsInstruction;
4903 *jns_offset_address = kJnsOffset;
4904 break;
4905 case ON_STACK_REPLACEMENT:
4906 case OSR_AFTER_STACK_CHECK:
4907 // sub <profiling_counter>, <delta> ;; Not changed
4908 // nop
4909 // nop
4910 // call <on-stack replacment>
4911 // ok:
4912 *jns_instr_address = kNopByteOne;
4913 *jns_offset_address = kNopByteTwo;
4914 break;
4915 }
4916
4910 Assembler::set_target_address_at(call_target_address, 4917 Assembler::set_target_address_at(call_target_address,
4911 replacement_code->entry()); 4918 replacement_code->entry());
4912
4913 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 4919 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
4914 unoptimized_code, call_target_address, replacement_code); 4920 unoptimized_code, call_target_address, replacement_code);
4915 } 4921 }
4916 4922
4917 4923
4918 void BackEdgeTable::RevertAt(Code* unoptimized_code, 4924 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState(
4919 Address pc_after, 4925 Isolate* isolate,
4920 Code* interrupt_code) { 4926 Code* unoptimized_code,
4921 // Restore the original jump. 4927 Address pc) {
4922 Address call_target_address = pc_after - kIntSize; 4928 Address call_target_address = pc - kIntSize;
4923 *(call_target_address - 3) = kJnsInstruction; 4929 Address jns_instr_address = call_target_address - 3;
4924 *(call_target_address - 2) = kJnsOffset; 4930 ASSERT_EQ(kCallInstruction, *(call_target_address - 1));
4925 // Restore the original call address.
4926 Assembler::set_target_address_at(call_target_address,
4927 interrupt_code->entry());
4928 4931
4929 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 4932 if (*jns_instr_address == kJnsInstruction) {
4930 unoptimized_code, call_target_address, interrupt_code); 4933 ASSERT_EQ(kJnsOffset, *(call_target_address - 2));
4934 ASSERT_EQ(isolate->builtins()->InterruptCheck()->entry(),
4935 Assembler::target_address_at(call_target_address));
4936 return INTERRUPT;
4937 }
4938
4939 ASSERT_EQ(kNopByteOne, *jns_instr_address);
4940 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2));
4941
4942 if (Assembler::target_address_at(call_target_address) ==
4943 isolate->builtins()->OnStackReplacement()->entry()) {
4944 return ON_STACK_REPLACEMENT;
4945 }
4946
4947 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4948 Assembler::target_address_at(call_target_address));
4949 return OSR_AFTER_STACK_CHECK;
4931 } 4950 }
4932 4951
4933 4952
4934 #ifdef DEBUG
4935 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState(
4936 Isolate* isolate,
4937 Code* unoptimized_code,
4938 Address pc_after) {
4939 Address call_target_address = pc_after - kIntSize;
4940 ASSERT_EQ(kCallInstruction, *(call_target_address - 1));
4941 if (*(call_target_address - 3) == kNopByteOne) {
4942 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2));
4943 Code* osr_builtin =
4944 isolate->builtins()->builtin(Builtins::kOnStackReplacement);
4945 ASSERT_EQ(osr_builtin->entry(),
4946 Assembler::target_address_at(call_target_address));
4947 return ON_STACK_REPLACEMENT;
4948 } else {
4949 // Get the interrupt stub code object to match against from cache.
4950 Code* interrupt_builtin =
4951 isolate->builtins()->builtin(Builtins::kInterruptCheck);
4952 ASSERT_EQ(interrupt_builtin->entry(),
4953 Assembler::target_address_at(call_target_address));
4954 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3));
4955 ASSERT_EQ(kJnsOffset, *(call_target_address - 2));
4956 return INTERRUPT;
4957 }
4958 }
4959 #endif // DEBUG
4960
4961
4962 } } // namespace v8::internal 4953 } } // namespace v8::internal
4963 4954
4964 #endif // V8_TARGET_ARCH_X64 4955 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698