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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/cpu-profiler.h" | 7 #include "src/cpu-profiler.h" |
8 #include "src/hydrogen-osr.h" | 8 #include "src/hydrogen-osr.h" |
9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 __ Branch(&loop, ne, a0, Operand(sp)); | 158 __ Branch(&loop, ne, a0, Operand(sp)); |
159 __ Pop(a0, a1); | 159 __ Pop(a0, a1); |
160 } else { | 160 } else { |
161 __ Dsubu(sp, sp, Operand(slots * kPointerSize)); | 161 __ Dsubu(sp, sp, Operand(slots * kPointerSize)); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 if (info()->saves_caller_doubles()) { | 165 if (info()->saves_caller_doubles()) { |
166 SaveCallerDoubles(); | 166 SaveCallerDoubles(); |
167 } | 167 } |
| 168 return !is_aborted(); |
| 169 } |
| 170 |
| 171 |
| 172 void LCodeGen::DoPrologue(LPrologue* instr) { |
| 173 Comment(";;; Prologue begin"); |
168 | 174 |
169 // Possibly allocate a local context. | 175 // Possibly allocate a local context. |
170 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 176 if (info()->scope()->num_heap_slots() > 0) { |
171 if (heap_slots > 0) { | |
172 Comment(";;; Allocate local context"); | 177 Comment(";;; Allocate local context"); |
173 bool need_write_barrier = true; | 178 bool need_write_barrier = true; |
174 // Argument to NewContext is the function, which is in a1. | 179 // Argument to NewContext is the function, which is in a1. |
175 DCHECK(!info()->scope()->is_script_scope()); | 180 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
176 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 181 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
177 FastNewContextStub stub(isolate(), heap_slots); | 182 if (info()->scope()->is_script_scope()) { |
| 183 __ push(a1); |
| 184 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
| 185 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 186 deopt_mode = Safepoint::kLazyDeopt; |
| 187 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 188 FastNewContextStub stub(isolate(), slots); |
178 __ CallStub(&stub); | 189 __ CallStub(&stub); |
179 // Result of FastNewContextStub is always in new space. | 190 // Result of FastNewContextStub is always in new space. |
180 need_write_barrier = false; | 191 need_write_barrier = false; |
181 } else { | 192 } else { |
182 __ push(a1); | 193 __ push(a1); |
183 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 194 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
184 } | 195 } |
185 RecordSafepoint(Safepoint::kNoLazyDeopt); | 196 RecordSafepoint(deopt_mode); |
| 197 |
186 // Context is returned in both v0. It replaces the context passed to us. | 198 // Context is returned in both v0. It replaces the context passed to us. |
187 // It's saved in the stack and kept live in cp. | 199 // It's saved in the stack and kept live in cp. |
188 __ mov(cp, v0); | 200 __ mov(cp, v0); |
189 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 201 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
190 // Copy any necessary parameters into the context. | 202 // Copy any necessary parameters into the context. |
191 int num_parameters = scope()->num_parameters(); | 203 int num_parameters = scope()->num_parameters(); |
192 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 204 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
193 for (int i = first_parameter; i < num_parameters; i++) { | 205 for (int i = first_parameter; i < num_parameters; i++) { |
194 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 206 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
195 if (var->IsContextSlot()) { | 207 if (var->IsContextSlot()) { |
(...skipping 12 matching lines...) Expand all Loading... |
208 Label done; | 220 Label done; |
209 __ JumpIfInNewSpace(cp, a0, &done); | 221 __ JumpIfInNewSpace(cp, a0, &done); |
210 __ Abort(kExpectedNewSpaceObject); | 222 __ Abort(kExpectedNewSpaceObject); |
211 __ bind(&done); | 223 __ bind(&done); |
212 } | 224 } |
213 } | 225 } |
214 } | 226 } |
215 Comment(";;; End allocate local context"); | 227 Comment(";;; End allocate local context"); |
216 } | 228 } |
217 | 229 |
218 // Trace the call. | 230 Comment(";;; Prologue end"); |
219 if (FLAG_trace && info()->IsOptimizing()) { | |
220 // We have not executed any compiled code yet, so cp still holds the | |
221 // incoming context. | |
222 __ CallRuntime(Runtime::kTraceEnter, 0); | |
223 } | |
224 return !is_aborted(); | |
225 } | 231 } |
226 | 232 |
227 | 233 |
228 void LCodeGen::GenerateOsrPrologue() { | 234 void LCodeGen::GenerateOsrPrologue() { |
229 // Generate the OSR entry prologue at the first unknown OSR value, or if there | 235 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
230 // are none, at the OSR entrypoint instruction. | 236 // are none, at the OSR entrypoint instruction. |
231 if (osr_pc_offset_ >= 0) return; | 237 if (osr_pc_offset_ >= 0) return; |
232 | 238 |
233 osr_pc_offset_ = masm()->pc_offset(); | 239 osr_pc_offset_ = masm()->pc_offset(); |
234 | 240 |
(...skipping 5877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6112 __ Push(at, ToRegister(instr->function())); | 6118 __ Push(at, ToRegister(instr->function())); |
6113 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6119 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6114 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6120 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6115 } | 6121 } |
6116 | 6122 |
6117 | 6123 |
6118 #undef __ | 6124 #undef __ |
6119 | 6125 |
6120 } // namespace internal | 6126 } // namespace internal |
6121 } // namespace v8 | 6127 } // namespace v8 |
OLD | NEW |