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

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

Issue 23526069: Refactor back edge table related code into a new class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/deoptimizer-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 4859 matching lines...) Expand 10 before | Expand all | Expand 10 after
4870 __ call(finally_entry_); 4870 __ call(finally_entry_);
4871 4871
4872 *stack_depth = 0; 4872 *stack_depth = 0;
4873 *context_length = 0; 4873 *context_length = 0;
4874 return previous_; 4874 return previous_;
4875 } 4875 }
4876 4876
4877 4877
4878 #undef __ 4878 #undef __
4879 4879
4880
4881 static const byte kJnsInstruction = 0x79;
4882 static const byte kJnsOffset = 0x1d;
4883 static const byte kCallInstruction = 0xe8;
4884 static const byte kNopByteOne = 0x66;
4885 static const byte kNopByteTwo = 0x90;
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
4902 void BackEdgeTable::PatchAt(Code* unoptimized_code,
4903 Address pc_after,
4904 Code* replacement_code) {
4905 // Turn the jump into nops.
4906 Address call_target_address = pc_after - kIntSize;
4907 *(call_target_address - 3) = kNopByteOne;
4908 *(call_target_address - 2) = kNopByteTwo;
4909 // Replace the call address.
4910 Assembler::set_target_address_at(call_target_address,
4911 replacement_code->entry());
4912
4913 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
4914 unoptimized_code, call_target_address, replacement_code);
4915 }
4916
4917
4918 void BackEdgeTable::RevertAt(Code* unoptimized_code,
4919 Address pc_after,
4920 Code* interrupt_code) {
4921 // Restore the original jump.
4922 Address call_target_address = pc_after - kIntSize;
4923 *(call_target_address - 3) = kJnsInstruction;
4924 *(call_target_address - 2) = kJnsOffset;
4925 // Restore the original call address.
4926 Assembler::set_target_address_at(call_target_address,
4927 interrupt_code->entry());
4928
4929 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
4930 unoptimized_code, call_target_address, interrupt_code);
4931 }
4932
4933
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
4880 } } // namespace v8::internal 4962 } } // namespace v8::internal
4881 4963
4882 #endif // V8_TARGET_ARCH_X64 4964 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/deoptimizer-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698