OLD | NEW |
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_ARM | 7 #if V8_TARGET_ARCH_ARM |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 private: | 82 private: |
83 MacroAssembler* masm_; | 83 MacroAssembler* masm_; |
84 Label patch_site_; | 84 Label patch_site_; |
85 #ifdef DEBUG | 85 #ifdef DEBUG |
86 bool info_emitted_; | 86 bool info_emitted_; |
87 #endif | 87 #endif |
88 }; | 88 }; |
89 | 89 |
90 | 90 |
91 static void EmitStackCheck(MacroAssembler* masm_, | |
92 Register stack_limit_scratch, | |
93 int pointers = 0, | |
94 Register scratch = sp) { | |
95 Isolate* isolate = masm_->isolate(); | |
96 Label ok; | |
97 ASSERT(scratch.is(sp) == (pointers == 0)); | |
98 Heap::RootListIndex index; | |
99 if (pointers != 0) { | |
100 __ sub(scratch, sp, Operand(pointers * kPointerSize)); | |
101 index = Heap::kRealStackLimitRootIndex; | |
102 } else { | |
103 index = Heap::kStackLimitRootIndex; | |
104 } | |
105 __ LoadRoot(stack_limit_scratch, index); | |
106 __ cmp(scratch, Operand(stack_limit_scratch)); | |
107 __ b(hs, &ok); | |
108 Handle<Code> stack_check = isolate->builtins()->StackCheck(); | |
109 PredictableCodeSizeScope predictable(masm_, | |
110 masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); | |
111 __ Call(stack_check, RelocInfo::CODE_TARGET); | |
112 __ bind(&ok); | |
113 } | |
114 | |
115 | |
116 // Generate code for a JS function. On entry to the function the receiver | 91 // Generate code for a JS function. On entry to the function the receiver |
117 // and arguments have been pushed on the stack left to right. The actual | 92 // and arguments have been pushed on the stack left to right. The actual |
118 // argument count matches the formal parameter count expected by the | 93 // argument count matches the formal parameter count expected by the |
119 // function. | 94 // function. |
120 // | 95 // |
121 // The live registers are: | 96 // The live registers are: |
122 // o r1: the JS function object being called (i.e., ourselves) | 97 // o r1: the JS function object being called (i.e., ourselves) |
123 // o cp: our context | 98 // o cp: our context |
124 // o pp: our caller's constant pool pointer (if FLAG_enable_ool_constant_pool) | 99 // o pp: our caller's constant pool pointer (if FLAG_enable_ool_constant_pool) |
125 // o fp: our caller's frame pointer | 100 // o fp: our caller's frame pointer |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 info->set_prologue_offset(masm_->pc_offset()); | 148 info->set_prologue_offset(masm_->pc_offset()); |
174 __ Prologue(info->IsCodePreAgingActive()); | 149 __ Prologue(info->IsCodePreAgingActive()); |
175 info->AddNoFrameRange(0, masm_->pc_offset()); | 150 info->AddNoFrameRange(0, masm_->pc_offset()); |
176 | 151 |
177 { Comment cmnt(masm_, "[ Allocate locals"); | 152 { Comment cmnt(masm_, "[ Allocate locals"); |
178 int locals_count = info->scope()->num_stack_slots(); | 153 int locals_count = info->scope()->num_stack_slots(); |
179 // Generators allocate locals, if any, in context slots. | 154 // Generators allocate locals, if any, in context slots. |
180 ASSERT(!info->function()->is_generator() || locals_count == 0); | 155 ASSERT(!info->function()->is_generator() || locals_count == 0); |
181 if (locals_count > 0) { | 156 if (locals_count > 0) { |
182 if (locals_count >= 128) { | 157 if (locals_count >= 128) { |
183 EmitStackCheck(masm_, r2, locals_count, r9); | 158 Label ok; |
| 159 __ sub(r9, sp, Operand(locals_count * kPointerSize)); |
| 160 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); |
| 161 __ cmp(r9, Operand(r2)); |
| 162 __ b(hs, &ok); |
| 163 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
| 164 __ bind(&ok); |
184 } | 165 } |
185 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | 166 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
186 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; | 167 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; |
187 if (locals_count >= kMaxPushes) { | 168 if (locals_count >= kMaxPushes) { |
188 int loop_iterations = locals_count / kMaxPushes; | 169 int loop_iterations = locals_count / kMaxPushes; |
189 __ mov(r2, Operand(loop_iterations)); | 170 __ mov(r2, Operand(loop_iterations)); |
190 Label loop_header; | 171 Label loop_header; |
191 __ bind(&loop_header); | 172 __ bind(&loop_header); |
192 // Do pushes. | 173 // Do pushes. |
193 for (int i = 0; i < kMaxPushes; i++) { | 174 for (int i = 0; i < kMaxPushes; i++) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ASSERT(function->proxy()->var()->mode() == CONST || | 295 ASSERT(function->proxy()->var()->mode() == CONST || |
315 function->proxy()->var()->mode() == CONST_LEGACY); | 296 function->proxy()->var()->mode() == CONST_LEGACY); |
316 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); | 297 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); |
317 VisitVariableDeclaration(function); | 298 VisitVariableDeclaration(function); |
318 } | 299 } |
319 VisitDeclarations(scope()->declarations()); | 300 VisitDeclarations(scope()->declarations()); |
320 } | 301 } |
321 | 302 |
322 { Comment cmnt(masm_, "[ Stack check"); | 303 { Comment cmnt(masm_, "[ Stack check"); |
323 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 304 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); |
324 EmitStackCheck(masm_, ip); | 305 Label ok; |
| 306 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 307 __ cmp(sp, Operand(ip)); |
| 308 __ b(hs, &ok); |
| 309 Handle<Code> stack_check = isolate()->builtins()->StackCheck(); |
| 310 PredictableCodeSizeScope predictable(masm_, |
| 311 masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); |
| 312 __ Call(stack_check, RelocInfo::CODE_TARGET); |
| 313 __ bind(&ok); |
325 } | 314 } |
326 | 315 |
327 { Comment cmnt(masm_, "[ Body"); | 316 { Comment cmnt(masm_, "[ Body"); |
328 ASSERT(loop_depth() == 0); | 317 ASSERT(loop_depth() == 0); |
329 VisitStatements(function()->body()); | 318 VisitStatements(function()->body()); |
330 ASSERT(loop_depth() == 0); | 319 ASSERT(loop_depth() == 0); |
331 } | 320 } |
332 } | 321 } |
333 | 322 |
334 // Always emit a 'return undefined' in case control fell off the end of | 323 // Always emit a 'return undefined' in case control fell off the end of |
(...skipping 4488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4823 | 4812 |
4824 ASSERT(interrupt_address == | 4813 ASSERT(interrupt_address == |
4825 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4814 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4826 return OSR_AFTER_STACK_CHECK; | 4815 return OSR_AFTER_STACK_CHECK; |
4827 } | 4816 } |
4828 | 4817 |
4829 | 4818 |
4830 } } // namespace v8::internal | 4819 } } // namespace v8::internal |
4831 | 4820 |
4832 #endif // V8_TARGET_ARCH_ARM | 4821 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |