OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 private: | 80 private: |
81 MacroAssembler* masm_; | 81 MacroAssembler* masm_; |
82 Label patch_site_; | 82 Label patch_site_; |
83 Register reg_; | 83 Register reg_; |
84 #ifdef DEBUG | 84 #ifdef DEBUG |
85 bool info_emitted_; | 85 bool info_emitted_; |
86 #endif | 86 #endif |
87 }; | 87 }; |
88 | 88 |
89 | 89 |
90 static void EmitStackCheck(MacroAssembler* masm_, | |
91 int pointers = 0, | |
92 Register scratch = jssp) { | |
93 Isolate* isolate = masm_->isolate(); | |
94 Label ok; | |
95 ASSERT(jssp.Is(__ StackPointer())); | |
96 ASSERT(scratch.Is(jssp) == (pointers == 0)); | |
97 Heap::RootListIndex index; | |
98 if (pointers != 0) { | |
99 __ Sub(scratch, jssp, pointers * kPointerSize); | |
100 index = Heap::kRealStackLimitRootIndex; | |
101 } else { | |
102 index = Heap::kStackLimitRootIndex; | |
103 } | |
104 __ CompareRoot(scratch, index); | |
105 __ B(hs, &ok); | |
106 PredictableCodeSizeScope predictable(masm_, | |
107 Assembler::kCallSizeWithRelocation); | |
108 __ Call(isolate->builtins()->StackCheck(), RelocInfo::CODE_TARGET); | |
109 __ Bind(&ok); | |
110 } | |
111 | |
112 | |
113 // Generate code for a JS function. On entry to the function the receiver | 90 // Generate code for a JS function. On entry to the function the receiver |
114 // and arguments have been pushed on the stack left to right. The actual | 91 // and arguments have been pushed on the stack left to right. The actual |
115 // argument count matches the formal parameter count expected by the | 92 // argument count matches the formal parameter count expected by the |
116 // function. | 93 // function. |
117 // | 94 // |
118 // The live registers are: | 95 // The live registers are: |
119 // - x1: the JS function object being called (i.e. ourselves). | 96 // - x1: the JS function object being called (i.e. ourselves). |
120 // - cp: our context. | 97 // - cp: our context. |
121 // - fp: our caller's frame pointer. | 98 // - fp: our caller's frame pointer. |
122 // - jssp: stack pointer. | 99 // - jssp: stack pointer. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 info->AddNoFrameRange(0, masm_->pc_offset()); | 151 info->AddNoFrameRange(0, masm_->pc_offset()); |
175 | 152 |
176 // Reserve space on the stack for locals. | 153 // Reserve space on the stack for locals. |
177 { Comment cmnt(masm_, "[ Allocate locals"); | 154 { Comment cmnt(masm_, "[ Allocate locals"); |
178 int locals_count = info->scope()->num_stack_slots(); | 155 int locals_count = info->scope()->num_stack_slots(); |
179 // Generators allocate locals, if any, in context slots. | 156 // Generators allocate locals, if any, in context slots. |
180 ASSERT(!info->function()->is_generator() || locals_count == 0); | 157 ASSERT(!info->function()->is_generator() || locals_count == 0); |
181 | 158 |
182 if (locals_count > 0) { | 159 if (locals_count > 0) { |
183 if (locals_count >= 128) { | 160 if (locals_count >= 128) { |
184 EmitStackCheck(masm_, locals_count, x10); | 161 Label ok; |
| 162 ASSERT(jssp.Is(__ StackPointer())); |
| 163 __ Sub(x10, jssp, locals_count * kPointerSize); |
| 164 __ CompareRoot(x10, Heap::kRealStackLimitRootIndex); |
| 165 __ B(hs, &ok); |
| 166 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
| 167 __ Bind(&ok); |
185 } | 168 } |
186 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); | 169 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); |
187 if (FLAG_optimize_for_size) { | 170 if (FLAG_optimize_for_size) { |
188 __ PushMultipleTimes(x10 , locals_count); | 171 __ PushMultipleTimes(x10 , locals_count); |
189 } else { | 172 } else { |
190 const int kMaxPushes = 32; | 173 const int kMaxPushes = 32; |
191 if (locals_count >= kMaxPushes) { | 174 if (locals_count >= kMaxPushes) { |
192 int loop_iterations = locals_count / kMaxPushes; | 175 int loop_iterations = locals_count / kMaxPushes; |
193 __ Mov(x3, loop_iterations); | 176 __ Mov(x3, loop_iterations); |
194 Label loop_header; | 177 Label loop_header; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 function->proxy()->var()->mode() == CONST_LEGACY); | 295 function->proxy()->var()->mode() == CONST_LEGACY); |
313 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); | 296 ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); |
314 VisitVariableDeclaration(function); | 297 VisitVariableDeclaration(function); |
315 } | 298 } |
316 VisitDeclarations(scope()->declarations()); | 299 VisitDeclarations(scope()->declarations()); |
317 } | 300 } |
318 } | 301 } |
319 | 302 |
320 { Comment cmnt(masm_, "[ Stack check"); | 303 { Comment cmnt(masm_, "[ Stack check"); |
321 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 304 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); |
322 EmitStackCheck(masm_); | 305 Label ok; |
| 306 ASSERT(jssp.Is(__ StackPointer())); |
| 307 __ CompareRoot(jssp, Heap::kStackLimitRootIndex); |
| 308 __ B(hs, &ok); |
| 309 PredictableCodeSizeScope predictable(masm_, |
| 310 Assembler::kCallSizeWithRelocation); |
| 311 __ Call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
| 312 __ Bind(&ok); |
323 } | 313 } |
324 | 314 |
325 { Comment cmnt(masm_, "[ Body"); | 315 { Comment cmnt(masm_, "[ Body"); |
326 ASSERT(loop_depth() == 0); | 316 ASSERT(loop_depth() == 0); |
327 VisitStatements(function()->body()); | 317 VisitStatements(function()->body()); |
328 ASSERT(loop_depth() == 0); | 318 ASSERT(loop_depth() == 0); |
329 } | 319 } |
330 | 320 |
331 // Always emit a 'return undefined' in case control fell off the end of | 321 // Always emit a 'return undefined' in case control fell off the end of |
332 // the body. | 322 // the body. |
(...skipping 4552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4885 return previous_; | 4875 return previous_; |
4886 } | 4876 } |
4887 | 4877 |
4888 | 4878 |
4889 #undef __ | 4879 #undef __ |
4890 | 4880 |
4891 | 4881 |
4892 } } // namespace v8::internal | 4882 } } // namespace v8::internal |
4893 | 4883 |
4894 #endif // V8_TARGET_ARCH_ARM64 | 4884 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |