OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/cpu-profiler.h" | 8 #include "src/cpu-profiler.h" |
9 #include "src/hydrogen-osr.h" | 9 #include "src/hydrogen-osr.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 __ bind(&loop); | 169 __ bind(&loop); |
170 __ StorePU(r4, MemOperand(r3, -kPointerSize)); | 170 __ StorePU(r4, MemOperand(r3, -kPointerSize)); |
171 __ bdnz(&loop); | 171 __ bdnz(&loop); |
172 __ Pop(r3, r4); | 172 __ Pop(r3, r4); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 if (info()->saves_caller_doubles()) { | 176 if (info()->saves_caller_doubles()) { |
177 SaveCallerDoubles(); | 177 SaveCallerDoubles(); |
178 } | 178 } |
| 179 return !is_aborted(); |
| 180 } |
| 181 |
| 182 |
| 183 void LCodeGen::DoPrologue(LPrologue* instr) { |
| 184 Comment(";;; Prologue begin"); |
179 | 185 |
180 // Possibly allocate a local context. | 186 // Possibly allocate a local context. |
181 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 187 if (info()->scope()->num_heap_slots() > 0) { |
182 if (heap_slots > 0) { | |
183 Comment(";;; Allocate local context"); | 188 Comment(";;; Allocate local context"); |
184 bool need_write_barrier = true; | 189 bool need_write_barrier = true; |
185 // Argument to NewContext is the function, which is in r4. | 190 // Argument to NewContext is the function, which is in r4. |
186 DCHECK(!info()->scope()->is_script_scope()); | 191 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
187 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 192 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
188 FastNewContextStub stub(isolate(), heap_slots); | 193 if (info()->scope()->is_script_scope()) { |
| 194 __ push(r4); |
| 195 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
| 196 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 197 deopt_mode = Safepoint::kLazyDeopt; |
| 198 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 199 FastNewContextStub stub(isolate(), slots); |
189 __ CallStub(&stub); | 200 __ CallStub(&stub); |
190 // Result of FastNewContextStub is always in new space. | 201 // Result of FastNewContextStub is always in new space. |
191 need_write_barrier = false; | 202 need_write_barrier = false; |
192 } else { | 203 } else { |
193 __ push(r4); | 204 __ push(r4); |
194 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 205 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
195 } | 206 } |
196 RecordSafepoint(Safepoint::kNoLazyDeopt); | 207 RecordSafepoint(deopt_mode); |
| 208 |
197 // Context is returned in both r3 and cp. It replaces the context | 209 // Context is returned in both r3 and cp. It replaces the context |
198 // passed to us. It's saved in the stack and kept live in cp. | 210 // passed to us. It's saved in the stack and kept live in cp. |
199 __ mr(cp, r3); | 211 __ mr(cp, r3); |
200 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 212 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
201 // Copy any necessary parameters into the context. | 213 // Copy any necessary parameters into the context. |
202 int num_parameters = scope()->num_parameters(); | 214 int num_parameters = scope()->num_parameters(); |
203 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 215 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
204 for (int i = first_parameter; i < num_parameters; i++) { | 216 for (int i = first_parameter; i < num_parameters; i++) { |
205 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 217 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
206 if (var->IsContextSlot()) { | 218 if (var->IsContextSlot()) { |
(...skipping 12 matching lines...) Expand all Loading... |
219 Label done; | 231 Label done; |
220 __ JumpIfInNewSpace(cp, r3, &done); | 232 __ JumpIfInNewSpace(cp, r3, &done); |
221 __ Abort(kExpectedNewSpaceObject); | 233 __ Abort(kExpectedNewSpaceObject); |
222 __ bind(&done); | 234 __ bind(&done); |
223 } | 235 } |
224 } | 236 } |
225 } | 237 } |
226 Comment(";;; End allocate local context"); | 238 Comment(";;; End allocate local context"); |
227 } | 239 } |
228 | 240 |
229 // Trace the call. | 241 Comment(";;; Prologue end"); |
230 if (FLAG_trace && info()->IsOptimizing()) { | |
231 // We have not executed any compiled code yet, so cp still holds the | |
232 // incoming context. | |
233 __ CallRuntime(Runtime::kTraceEnter, 0); | |
234 } | |
235 return !is_aborted(); | |
236 } | 242 } |
237 | 243 |
238 | 244 |
239 void LCodeGen::GenerateOsrPrologue() { | 245 void LCodeGen::GenerateOsrPrologue() { |
240 // Generate the OSR entry prologue at the first unknown OSR value, or if there | 246 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
241 // are none, at the OSR entrypoint instruction. | 247 // are none, at the OSR entrypoint instruction. |
242 if (osr_pc_offset_ >= 0) return; | 248 if (osr_pc_offset_ >= 0) return; |
243 | 249 |
244 osr_pc_offset_ = masm()->pc_offset(); | 250 osr_pc_offset_ = masm()->pc_offset(); |
245 | 251 |
(...skipping 5909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6155 __ Push(scope_info); | 6161 __ Push(scope_info); |
6156 __ push(ToRegister(instr->function())); | 6162 __ push(ToRegister(instr->function())); |
6157 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6163 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6158 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6164 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6159 } | 6165 } |
6160 | 6166 |
6161 | 6167 |
6162 #undef __ | 6168 #undef __ |
6163 } // namespace internal | 6169 } // namespace internal |
6164 } // namespace v8 | 6170 } // namespace v8 |
OLD | NEW |