OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 __ Branch(&loop, ne, a0, Operand(sp)); | 183 __ Branch(&loop, ne, a0, Operand(sp)); |
184 __ Pop(a0, a1); | 184 __ Pop(a0, a1); |
185 } else { | 185 } else { |
186 __ Subu(sp, sp, Operand(slots * kPointerSize)); | 186 __ Subu(sp, sp, Operand(slots * kPointerSize)); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 if (info()->saves_caller_doubles()) { | 190 if (info()->saves_caller_doubles()) { |
191 SaveCallerDoubles(); | 191 SaveCallerDoubles(); |
192 } | 192 } |
| 193 return !is_aborted(); |
| 194 } |
| 195 |
| 196 |
| 197 void LCodeGen::DoPrologue(LPrologue* instr) { |
| 198 Comment(";;; Prologue begin"); |
193 | 199 |
194 // Possibly allocate a local context. | 200 // Possibly allocate a local context. |
195 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 201 if (info()->scope()->num_heap_slots() > 0) { |
196 if (heap_slots > 0) { | |
197 Comment(";;; Allocate local context"); | 202 Comment(";;; Allocate local context"); |
198 bool need_write_barrier = true; | 203 bool need_write_barrier = true; |
199 // Argument to NewContext is the function, which is in a1. | 204 // Argument to NewContext is the function, which is in a1. |
200 DCHECK(!info()->scope()->is_script_scope()); | 205 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
201 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 206 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
202 FastNewContextStub stub(isolate(), heap_slots); | 207 if (info()->scope()->is_script_scope()) { |
| 208 __ push(a1); |
| 209 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
| 210 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 211 deopt_mode = Safepoint::kLazyDeopt; |
| 212 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 213 FastNewContextStub stub(isolate(), slots); |
203 __ CallStub(&stub); | 214 __ CallStub(&stub); |
204 // Result of FastNewContextStub is always in new space. | 215 // Result of FastNewContextStub is always in new space. |
205 need_write_barrier = false; | 216 need_write_barrier = false; |
206 } else { | 217 } else { |
207 __ push(a1); | 218 __ push(a1); |
208 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 219 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
209 } | 220 } |
210 RecordSafepoint(Safepoint::kNoLazyDeopt); | 221 RecordSafepoint(deopt_mode); |
| 222 |
211 // Context is returned in both v0. It replaces the context passed to us. | 223 // Context is returned in both v0. It replaces the context passed to us. |
212 // It's saved in the stack and kept live in cp. | 224 // It's saved in the stack and kept live in cp. |
213 __ mov(cp, v0); | 225 __ mov(cp, v0); |
214 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 226 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
215 // Copy any necessary parameters into the context. | 227 // Copy any necessary parameters into the context. |
216 int num_parameters = scope()->num_parameters(); | 228 int num_parameters = scope()->num_parameters(); |
217 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 229 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
218 for (int i = first_parameter; i < num_parameters; i++) { | 230 for (int i = first_parameter; i < num_parameters; i++) { |
219 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 231 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
220 if (var->IsContextSlot()) { | 232 if (var->IsContextSlot()) { |
(...skipping 12 matching lines...) Expand all Loading... |
233 Label done; | 245 Label done; |
234 __ JumpIfInNewSpace(cp, a0, &done); | 246 __ JumpIfInNewSpace(cp, a0, &done); |
235 __ Abort(kExpectedNewSpaceObject); | 247 __ Abort(kExpectedNewSpaceObject); |
236 __ bind(&done); | 248 __ bind(&done); |
237 } | 249 } |
238 } | 250 } |
239 } | 251 } |
240 Comment(";;; End allocate local context"); | 252 Comment(";;; End allocate local context"); |
241 } | 253 } |
242 | 254 |
243 // Trace the call. | 255 Comment(";;; Prologue end"); |
244 if (FLAG_trace && info()->IsOptimizing()) { | |
245 // We have not executed any compiled code yet, so cp still holds the | |
246 // incoming context. | |
247 __ CallRuntime(Runtime::kTraceEnter, 0); | |
248 } | |
249 return !is_aborted(); | |
250 } | 256 } |
251 | 257 |
252 | 258 |
253 void LCodeGen::GenerateOsrPrologue() { | 259 void LCodeGen::GenerateOsrPrologue() { |
254 // Generate the OSR entry prologue at the first unknown OSR value, or if there | 260 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
255 // are none, at the OSR entrypoint instruction. | 261 // are none, at the OSR entrypoint instruction. |
256 if (osr_pc_offset_ >= 0) return; | 262 if (osr_pc_offset_ >= 0) return; |
257 | 263 |
258 osr_pc_offset_ = masm()->pc_offset(); | 264 osr_pc_offset_ = masm()->pc_offset(); |
259 | 265 |
(...skipping 5665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5925 __ Push(at, ToRegister(instr->function())); | 5931 __ Push(at, ToRegister(instr->function())); |
5926 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5932 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5927 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5933 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5928 } | 5934 } |
5929 | 5935 |
5930 | 5936 |
5931 #undef __ | 5937 #undef __ |
5932 | 5938 |
5933 } // namespace internal | 5939 } // namespace internal |
5934 } // namespace v8 | 5940 } // namespace v8 |
OLD | NEW |