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

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

Issue 336413009: X87: Interrupts must not mask stack overflow. (Closed) Base URL: https://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | src/x87/regexp-macro-assembler-x87.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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 MacroAssembler* masm_; 73 MacroAssembler* masm_;
74 Label patch_site_; 74 Label patch_site_;
75 #ifdef DEBUG 75 #ifdef DEBUG
76 bool info_emitted_; 76 bool info_emitted_;
77 #endif 77 #endif
78 }; 78 };
79 79
80 80
81 static void EmitStackCheck(MacroAssembler* masm_,
82 int pointers = 0,
83 Register scratch = esp) {
84 Label ok;
85 Isolate* isolate = masm_->isolate();
86 ASSERT(scratch.is(esp) == (pointers == 0));
87 ExternalReference stack_limit;
88 if (pointers != 0) {
89 __ mov(scratch, esp);
90 __ sub(scratch, Immediate(pointers * kPointerSize));
91 stack_limit = ExternalReference::address_of_real_stack_limit(isolate);
92 } else {
93 stack_limit = ExternalReference::address_of_stack_limit(isolate);
94 }
95 __ cmp(scratch, Operand::StaticVariable(stack_limit));
96 __ j(above_equal, &ok, Label::kNear);
97 __ call(isolate->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
98 __ bind(&ok);
99 }
100
101
102 // Generate code for a JS function. On entry to the function the receiver 81 // Generate code for a JS function. On entry to the function the receiver
103 // and arguments have been pushed on the stack left to right, with the 82 // and arguments have been pushed on the stack left to right, with the
104 // return address on top of them. The actual argument count matches the 83 // return address on top of them. The actual argument count matches the
105 // formal parameter count expected by the function. 84 // formal parameter count expected by the function.
106 // 85 //
107 // The live registers are: 86 // The live registers are:
108 // o edi: the JS function object being called (i.e. ourselves) 87 // o edi: the JS function object being called (i.e. ourselves)
109 // o esi: our context 88 // o esi: our context
110 // o ebp: our caller's frame pointer 89 // o ebp: our caller's frame pointer
111 // o esp: stack pointer (pointing to return address) 90 // o esp: stack pointer (pointing to return address)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 info->AddNoFrameRange(0, masm_->pc_offset()); 140 info->AddNoFrameRange(0, masm_->pc_offset());
162 141
163 { Comment cmnt(masm_, "[ Allocate locals"); 142 { Comment cmnt(masm_, "[ Allocate locals");
164 int locals_count = info->scope()->num_stack_slots(); 143 int locals_count = info->scope()->num_stack_slots();
165 // Generators allocate locals, if any, in context slots. 144 // Generators allocate locals, if any, in context slots.
166 ASSERT(!info->function()->is_generator() || locals_count == 0); 145 ASSERT(!info->function()->is_generator() || locals_count == 0);
167 if (locals_count == 1) { 146 if (locals_count == 1) {
168 __ push(Immediate(isolate()->factory()->undefined_value())); 147 __ push(Immediate(isolate()->factory()->undefined_value()));
169 } else if (locals_count > 1) { 148 } else if (locals_count > 1) {
170 if (locals_count >= 128) { 149 if (locals_count >= 128) {
171 EmitStackCheck(masm_, locals_count, ecx); 150 Label ok;
151 __ mov(ecx, esp);
152 __ sub(ecx, Immediate(locals_count * kPointerSize));
153 ExternalReference stack_limit =
154 ExternalReference::address_of_real_stack_limit(isolate());
155 __ cmp(ecx, Operand::StaticVariable(stack_limit));
156 __ j(above_equal, &ok, Label::kNear);
157 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
158 __ bind(&ok);
172 } 159 }
173 __ mov(eax, Immediate(isolate()->factory()->undefined_value())); 160 __ mov(eax, Immediate(isolate()->factory()->undefined_value()));
174 const int kMaxPushes = 32; 161 const int kMaxPushes = 32;
175 if (locals_count >= kMaxPushes) { 162 if (locals_count >= kMaxPushes) {
176 int loop_iterations = locals_count / kMaxPushes; 163 int loop_iterations = locals_count / kMaxPushes;
177 __ mov(ecx, loop_iterations); 164 __ mov(ecx, loop_iterations);
178 Label loop_header; 165 Label loop_header;
179 __ bind(&loop_header); 166 __ bind(&loop_header);
180 // Do pushes. 167 // Do pushes.
181 for (int i = 0; i < kMaxPushes; i++) { 168 for (int i = 0; i < kMaxPushes; i++) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 ASSERT(function->proxy()->var()->mode() == CONST || 288 ASSERT(function->proxy()->var()->mode() == CONST ||
302 function->proxy()->var()->mode() == CONST_LEGACY); 289 function->proxy()->var()->mode() == CONST_LEGACY);
303 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); 290 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED);
304 VisitVariableDeclaration(function); 291 VisitVariableDeclaration(function);
305 } 292 }
306 VisitDeclarations(scope()->declarations()); 293 VisitDeclarations(scope()->declarations());
307 } 294 }
308 295
309 { Comment cmnt(masm_, "[ Stack check"); 296 { Comment cmnt(masm_, "[ Stack check");
310 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); 297 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
311 EmitStackCheck(masm_); 298 Label ok;
299 ExternalReference stack_limit
300 = ExternalReference::address_of_stack_limit(isolate());
301 __ cmp(esp, Operand::StaticVariable(stack_limit));
302 __ j(above_equal, &ok, Label::kNear);
303 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
304 __ bind(&ok);
312 } 305 }
313 306
314 { Comment cmnt(masm_, "[ Body"); 307 { Comment cmnt(masm_, "[ Body");
315 ASSERT(loop_depth() == 0); 308 ASSERT(loop_depth() == 0);
316 VisitStatements(function()->body()); 309 VisitStatements(function()->body());
317 ASSERT(loop_depth() == 0); 310 ASSERT(loop_depth() == 0);
318 } 311 }
319 } 312 }
320 313
321 // Always emit a 'return undefined' in case control fell off the end of 314 // Always emit a 'return undefined' in case control fell off the end of
(...skipping 4467 matching lines...) Expand 10 before | Expand all | Expand 10 after
4789 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4782 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4790 Assembler::target_address_at(call_target_address, 4783 Assembler::target_address_at(call_target_address,
4791 unoptimized_code)); 4784 unoptimized_code));
4792 return OSR_AFTER_STACK_CHECK; 4785 return OSR_AFTER_STACK_CHECK;
4793 } 4786 }
4794 4787
4795 4788
4796 } } // namespace v8::internal 4789 } } // namespace v8::internal
4797 4790
4798 #endif // V8_TARGET_ARCH_X87 4791 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/regexp-macro-assembler-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698