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/crankshaft/arm/lithium-codegen-arm.h" | 5 #include "src/crankshaft/arm/lithium-codegen-arm.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/crankshaft/arm/lithium-gap-resolver-arm.h" | 10 #include "src/crankshaft/arm/lithium-gap-resolver-arm.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Possibly allocate a local context. | 162 // Possibly allocate a local context. |
163 if (info()->scope()->num_heap_slots() > 0) { | 163 if (info()->scope()->num_heap_slots() > 0) { |
164 Comment(";;; Allocate local context"); | 164 Comment(";;; Allocate local context"); |
165 bool need_write_barrier = true; | 165 bool need_write_barrier = true; |
166 // Argument to NewContext is the function, which is in r1. | 166 // Argument to NewContext is the function, which is in r1. |
167 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 167 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
168 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; | 168 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
169 if (info()->scope()->is_script_scope()) { | 169 if (info()->scope()->is_script_scope()) { |
170 __ push(r1); | 170 __ push(r1); |
171 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); | 171 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
172 __ CallRuntime(Runtime::kNewScriptContext, 2); | 172 __ CallRuntime(Runtime::kNewScriptContext); |
173 deopt_mode = Safepoint::kLazyDeopt; | 173 deopt_mode = Safepoint::kLazyDeopt; |
174 } else if (slots <= FastNewContextStub::kMaximumSlots) { | 174 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
175 FastNewContextStub stub(isolate(), slots); | 175 FastNewContextStub stub(isolate(), slots); |
176 __ CallStub(&stub); | 176 __ CallStub(&stub); |
177 // Result of FastNewContextStub is always in new space. | 177 // Result of FastNewContextStub is always in new space. |
178 need_write_barrier = false; | 178 need_write_barrier = false; |
179 } else { | 179 } else { |
180 __ push(r1); | 180 __ push(r1); |
181 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 181 __ CallRuntime(Runtime::kNewFunctionContext); |
182 } | 182 } |
183 RecordSafepoint(deopt_mode); | 183 RecordSafepoint(deopt_mode); |
184 | 184 |
185 // Context is returned in both r0 and cp. It replaces the context | 185 // Context is returned in both r0 and cp. It replaces the context |
186 // passed to us. It's saved in the stack and kept live in cp. | 186 // passed to us. It's saved in the stack and kept live in cp. |
187 __ mov(cp, r0); | 187 __ mov(cp, r0); |
188 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 188 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
189 // Copy any necessary parameters into the context. | 189 // Copy any necessary parameters into the context. |
190 int num_parameters = scope()->num_parameters(); | 190 int num_parameters = scope()->num_parameters(); |
191 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 191 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
(...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 | 2667 |
2668 | 2668 |
2669 void LCodeGen::DoReturn(LReturn* instr) { | 2669 void LCodeGen::DoReturn(LReturn* instr) { |
2670 if (FLAG_trace && info()->IsOptimizing()) { | 2670 if (FLAG_trace && info()->IsOptimizing()) { |
2671 // Push the return value on the stack as the parameter. | 2671 // Push the return value on the stack as the parameter. |
2672 // Runtime::TraceExit returns its parameter in r0. We're leaving the code | 2672 // Runtime::TraceExit returns its parameter in r0. We're leaving the code |
2673 // managed by the register allocator and tearing down the frame, it's | 2673 // managed by the register allocator and tearing down the frame, it's |
2674 // safe to write to the context register. | 2674 // safe to write to the context register. |
2675 __ push(r0); | 2675 __ push(r0); |
2676 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2676 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2677 __ CallRuntime(Runtime::kTraceExit, 1); | 2677 __ CallRuntime(Runtime::kTraceExit); |
2678 } | 2678 } |
2679 if (info()->saves_caller_doubles()) { | 2679 if (info()->saves_caller_doubles()) { |
2680 RestoreCallerDoubles(); | 2680 RestoreCallerDoubles(); |
2681 } | 2681 } |
2682 if (NeedsEagerFrame()) { | 2682 if (NeedsEagerFrame()) { |
2683 masm_->LeaveFrame(StackFrame::JAVA_SCRIPT); | 2683 masm_->LeaveFrame(StackFrame::JAVA_SCRIPT); |
2684 } | 2684 } |
2685 { ConstantPoolUnavailableScope constant_pool_unavailable(masm()); | 2685 { ConstantPoolUnavailableScope constant_pool_unavailable(masm()); |
2686 if (instr->has_constant_parameter_count()) { | 2686 if (instr->has_constant_parameter_count()) { |
2687 int parameter_count = ToInteger32(instr->constant_parameter_count()); | 2687 int parameter_count = ToInteger32(instr->constant_parameter_count()); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 } | 3326 } |
3327 } | 3327 } |
3328 | 3328 |
3329 | 3329 |
3330 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { | 3330 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { |
3331 DCHECK(ToRegister(instr->context()).is(cp)); | 3331 DCHECK(ToRegister(instr->context()).is(cp)); |
3332 __ Move(scratch0(), instr->hydrogen()->pairs()); | 3332 __ Move(scratch0(), instr->hydrogen()->pairs()); |
3333 __ push(scratch0()); | 3333 __ push(scratch0()); |
3334 __ mov(scratch0(), Operand(Smi::FromInt(instr->hydrogen()->flags()))); | 3334 __ mov(scratch0(), Operand(Smi::FromInt(instr->hydrogen()->flags()))); |
3335 __ push(scratch0()); | 3335 __ push(scratch0()); |
3336 CallRuntime(Runtime::kDeclareGlobals, 2, instr); | 3336 CallRuntime(Runtime::kDeclareGlobals, instr); |
3337 } | 3337 } |
3338 | 3338 |
3339 | 3339 |
3340 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 3340 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
3341 int formal_parameter_count, int arity, | 3341 int formal_parameter_count, int arity, |
3342 LInstruction* instr) { | 3342 LInstruction* instr) { |
3343 bool dont_adapt_arguments = | 3343 bool dont_adapt_arguments = |
3344 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3344 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
3345 bool can_invoke_directly = | 3345 bool can_invoke_directly = |
3346 dont_adapt_arguments || formal_parameter_count == arity; | 3346 dont_adapt_arguments || formal_parameter_count == arity; |
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5495 Register null_value = r5; | 5495 Register null_value = r5; |
5496 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 5496 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
5497 __ CheckEnumCache(null_value, &call_runtime); | 5497 __ CheckEnumCache(null_value, &call_runtime); |
5498 | 5498 |
5499 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 5499 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
5500 __ b(&use_cache); | 5500 __ b(&use_cache); |
5501 | 5501 |
5502 // Get the set of properties to enumerate. | 5502 // Get the set of properties to enumerate. |
5503 __ bind(&call_runtime); | 5503 __ bind(&call_runtime); |
5504 __ push(r0); | 5504 __ push(r0); |
5505 CallRuntime(Runtime::kGetPropertyNamesFast, 1, instr); | 5505 CallRuntime(Runtime::kGetPropertyNamesFast, instr); |
5506 | 5506 |
5507 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 5507 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
5508 __ LoadRoot(ip, Heap::kMetaMapRootIndex); | 5508 __ LoadRoot(ip, Heap::kMetaMapRootIndex); |
5509 __ cmp(r1, ip); | 5509 __ cmp(r1, ip); |
5510 DeoptimizeIf(ne, instr, Deoptimizer::kWrongMap); | 5510 DeoptimizeIf(ne, instr, Deoptimizer::kWrongMap); |
5511 __ bind(&use_cache); | 5511 __ bind(&use_cache); |
5512 } | 5512 } |
5513 | 5513 |
5514 | 5514 |
5515 void LCodeGen::DoForInCacheArray(LForInCacheArray* instr) { | 5515 void LCodeGen::DoForInCacheArray(LForInCacheArray* instr) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5623 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { | 5623 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { |
5624 Register context = ToRegister(instr->context()); | 5624 Register context = ToRegister(instr->context()); |
5625 __ str(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 5625 __ str(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
5626 } | 5626 } |
5627 | 5627 |
5628 | 5628 |
5629 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { | 5629 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { |
5630 Handle<ScopeInfo> scope_info = instr->scope_info(); | 5630 Handle<ScopeInfo> scope_info = instr->scope_info(); |
5631 __ Push(scope_info); | 5631 __ Push(scope_info); |
5632 __ push(ToRegister(instr->function())); | 5632 __ push(ToRegister(instr->function())); |
5633 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5633 CallRuntime(Runtime::kPushBlockContext, instr); |
5634 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5634 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5635 } | 5635 } |
5636 | 5636 |
5637 | 5637 |
5638 #undef __ | 5638 #undef __ |
5639 | 5639 |
5640 } // namespace internal | 5640 } // namespace internal |
5641 } // namespace v8 | 5641 } // namespace v8 |
OLD | NEW |