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

Side by Side Diff: src/ia32/deoptimizer-ia32.cc

Issue 6005014: Small change to stack checks in unoptimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 9 years, 11 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/full-codegen-arm.cc ('k') | src/ia32/full-codegen-ia32.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (FLAG_trace_deopt) { 98 if (FLAG_trace_deopt) {
99 PrintF("[forced deoptimization: "); 99 PrintF("[forced deoptimization: ");
100 function->PrintName(); 100 function->PrintName();
101 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); 101 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
102 } 102 }
103 } 103 }
104 104
105 105
106 void Deoptimizer::PatchStackCheckCode(RelocInfo* rinfo, 106 void Deoptimizer::PatchStackCheckCode(RelocInfo* rinfo,
107 Code* replacement_code) { 107 Code* replacement_code) {
108 // The stack check code matches the pattern (on ia32, for example): 108 // The stack check code matches the pattern:
109 // 109 //
110 // cmp esp, <limit> 110 // cmp esp, <limit>
111 // jae ok 111 // jae ok
112 // call <stack guard> 112 // call <stack guard>
113 // test eax, <loop nesting depth>
113 // ok: ... 114 // ok: ...
114 // 115 //
115 // We will patch the code to: 116 // We will patch away the branch so the code is:
116 // 117 //
117 // cmp esp, <limit> ;; Not changed 118 // cmp esp, <limit> ;; Not changed
118 // nop 119 // nop
119 // nop 120 // nop
120 // call <on-stack replacment> 121 // call <on-stack replacment>
122 // test eax, <loop nesting depth>
121 // ok: 123 // ok:
122 Address call_target_address = rinfo->pc(); 124 Address call_target_address = rinfo->pc();
123 ASSERT(*(call_target_address - 3) == 0x73 && // jae 125 ASSERT(*(call_target_address - 3) == 0x73 && // jae
124 *(call_target_address - 2) == 0x05 && // offset 126 *(call_target_address - 2) == 0x07 && // offset
125 *(call_target_address - 1) == 0xe8); // call 127 *(call_target_address - 1) == 0xe8); // call
126 *(call_target_address - 3) = 0x90; // nop 128 *(call_target_address - 3) = 0x90; // nop
127 *(call_target_address - 2) = 0x90; // nop 129 *(call_target_address - 2) = 0x90; // nop
128 rinfo->set_target_address(replacement_code->entry()); 130 rinfo->set_target_address(replacement_code->entry());
129 } 131 }
130 132
131 133
132 void Deoptimizer::RevertStackCheckCode(RelocInfo* rinfo, Code* check_code) { 134 void Deoptimizer::RevertStackCheckCode(RelocInfo* rinfo, Code* check_code) {
135 // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to
136 // restore the conditional branch.
133 Address call_target_address = rinfo->pc(); 137 Address call_target_address = rinfo->pc();
134 ASSERT(*(call_target_address - 3) == 0x90 && // nop 138 ASSERT(*(call_target_address - 3) == 0x90 && // nop
135 *(call_target_address - 2) == 0x90 && // nop 139 *(call_target_address - 2) == 0x90 && // nop
136 *(call_target_address - 1) == 0xe8); // call 140 *(call_target_address - 1) == 0xe8); // call
137 *(call_target_address - 3) = 0x73; // jae 141 *(call_target_address - 3) = 0x73; // jae
138 *(call_target_address - 2) = 0x05; // offset 142 *(call_target_address - 2) = 0x07; // offset
139 rinfo->set_target_address(check_code->entry()); 143 rinfo->set_target_address(check_code->entry());
140 } 144 }
141 145
142 146
143 static int LookupBailoutId(DeoptimizationInputData* data, unsigned ast_id) { 147 static int LookupBailoutId(DeoptimizationInputData* data, unsigned ast_id) {
144 ByteArray* translations = data->TranslationByteArray(); 148 ByteArray* translations = data->TranslationByteArray();
145 int length = data->DeoptCount(); 149 int length = data->DeoptCount();
146 for (int i = 0; i < length; i++) { 150 for (int i = 0; i < length; i++) {
147 if (static_cast<unsigned>(data->AstId(i)->value()) == ast_id) { 151 if (static_cast<unsigned>(data->AstId(i)->value()) == ast_id) {
148 TranslationIterator it(translations, data->TranslationIndex(i)->value()); 152 TranslationIterator it(translations, data->TranslationIndex(i)->value());
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 __ jmp(&done); 610 __ jmp(&done);
607 ASSERT(masm()->pc_offset() - start == table_entry_size_); 611 ASSERT(masm()->pc_offset() - start == table_entry_size_);
608 } 612 }
609 __ bind(&done); 613 __ bind(&done);
610 } 614 }
611 615
612 #undef __ 616 #undef __
613 617
614 618
615 } } // namespace v8::internal 619 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698