| 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-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 info->set_prologue_offset(masm_->pc_offset()); | 149 info->set_prologue_offset(masm_->pc_offset()); |
| 150 __ Prologue(info->IsCodePreAgingActive()); | 150 __ Prologue(info->IsCodePreAgingActive()); |
| 151 info->AddNoFrameRange(0, masm_->pc_offset()); | 151 info->AddNoFrameRange(0, masm_->pc_offset()); |
| 152 | 152 |
| 153 { Comment cmnt(masm_, "[ Allocate locals"); | 153 { Comment cmnt(masm_, "[ Allocate locals"); |
| 154 int locals_count = info->scope()->num_stack_slots(); | 154 int locals_count = info->scope()->num_stack_slots(); |
| 155 // Generators allocate locals, if any, in context slots. | 155 // Generators allocate locals, if any, in context slots. |
| 156 DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0); | 156 DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0); |
| 157 if (locals_count > 0) { | 157 if (locals_count > 0) { |
| 158 if (locals_count >= 128) { | 158 EmitPreemptiveStackCheck(locals_count); |
| 159 Label ok; | |
| 160 __ sub(r9, sp, Operand(locals_count * kPointerSize)); | |
| 161 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); | |
| 162 __ cmp(r9, Operand(r2)); | |
| 163 __ b(hs, &ok); | |
| 164 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | |
| 165 __ bind(&ok); | |
| 166 } | |
| 167 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | 159 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
| 168 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; | 160 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; |
| 169 if (locals_count >= kMaxPushes) { | 161 if (locals_count >= kMaxPushes) { |
| 170 int loop_iterations = locals_count / kMaxPushes; | 162 int loop_iterations = locals_count / kMaxPushes; |
| 171 __ mov(r2, Operand(loop_iterations)); | 163 __ mov(r2, Operand(loop_iterations)); |
| 172 Label loop_header; | 164 Label loop_header; |
| 173 __ bind(&loop_header); | 165 __ bind(&loop_header); |
| 174 // Do pushes. | 166 // Do pushes. |
| 175 for (int i = 0; i < kMaxPushes; i++) { | 167 for (int i = 0; i < kMaxPushes; i++) { |
| 176 __ push(r9); | 168 __ push(r9); |
| (...skipping 2851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3028 // - target function | 3020 // - target function |
| 3029 // - this (receiver) | 3021 // - this (receiver) |
| 3030 EmitCall(expr, CallICState::METHOD); | 3022 EmitCall(expr, CallICState::METHOD); |
| 3031 } | 3023 } |
| 3032 | 3024 |
| 3033 | 3025 |
| 3034 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 3026 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
| 3035 // Load the arguments. | 3027 // Load the arguments. |
| 3036 ZoneList<Expression*>* args = expr->arguments(); | 3028 ZoneList<Expression*>* args = expr->arguments(); |
| 3037 int arg_count = args->length(); | 3029 int arg_count = args->length(); |
| 3030 |
| 3031 EmitPreemptiveStackCheck(arg_count); |
| 3032 |
| 3038 { PreservePositionScope scope(masm()->positions_recorder()); | 3033 { PreservePositionScope scope(masm()->positions_recorder()); |
| 3039 for (int i = 0; i < arg_count; i++) { | 3034 for (int i = 0; i < arg_count; i++) { |
| 3040 VisitForStackValue(args->at(i)); | 3035 VisitForStackValue(args->at(i)); |
| 3041 } | 3036 } |
| 3042 } | 3037 } |
| 3043 | 3038 |
| 3044 // Record source position of the IC call. | 3039 // Record source position of the IC call. |
| 3045 SetSourcePosition(expr->position()); | 3040 SetSourcePosition(expr->position()); |
| 3046 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 3041 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); |
| 3047 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); | 3042 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); |
| (...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 } else { | 5204 } else { |
| 5210 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); | 5205 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); |
| 5211 CallIC(ic, expr->CompareOperationFeedbackId()); | 5206 CallIC(ic, expr->CompareOperationFeedbackId()); |
| 5212 __ cmp(r0, Operand(0)); | 5207 __ cmp(r0, Operand(0)); |
| 5213 Split(ne, if_true, if_false, fall_through); | 5208 Split(ne, if_true, if_false, fall_through); |
| 5214 } | 5209 } |
| 5215 context()->Plug(if_true, if_false); | 5210 context()->Plug(if_true, if_false); |
| 5216 } | 5211 } |
| 5217 | 5212 |
| 5218 | 5213 |
| 5214 void FullCodeGenerator::EmitPreemptiveStackCheck(int required_stack_size) { |
| 5215 if (required_stack_size >= 128) { |
| 5216 Label ok; |
| 5217 __ sub(r9, sp, Operand(required_stack_size * kPointerSize)); |
| 5218 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); |
| 5219 __ cmp(r9, Operand(r2)); |
| 5220 __ b(hs, &ok); |
| 5221 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
| 5222 __ bind(&ok); |
| 5223 } |
| 5224 } |
| 5225 |
| 5226 |
| 5219 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 5227 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 5220 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 5228 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 5221 context()->Plug(r0); | 5229 context()->Plug(r0); |
| 5222 } | 5230 } |
| 5223 | 5231 |
| 5224 | 5232 |
| 5225 Register FullCodeGenerator::result_register() { | 5233 Register FullCodeGenerator::result_register() { |
| 5226 return r0; | 5234 return r0; |
| 5227 } | 5235 } |
| 5228 | 5236 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5501 | 5509 |
| 5502 DCHECK(interrupt_address == | 5510 DCHECK(interrupt_address == |
| 5503 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5511 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5504 return OSR_AFTER_STACK_CHECK; | 5512 return OSR_AFTER_STACK_CHECK; |
| 5505 } | 5513 } |
| 5506 | 5514 |
| 5507 | 5515 |
| 5508 } } // namespace v8::internal | 5516 } } // namespace v8::internal |
| 5509 | 5517 |
| 5510 #endif // V8_TARGET_ARCH_ARM | 5518 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |