Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: src/full-codegen/ppc/full-codegen-ppc.cc

Issue 1324023002: PPC: Crankshaft is now able to compile top level code even if there is a ScriptContext. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ppc/lithium-codegen-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_PPC 5 #if V8_TARGET_ARCH_PPC
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 __ bdnz(&loop_header); 179 __ bdnz(&loop_header);
180 } 180 }
181 int remaining = locals_count % kMaxPushes; 181 int remaining = locals_count % kMaxPushes;
182 // Emit the remaining pushes. 182 // Emit the remaining pushes.
183 for (int i = 0; i < remaining; i++) { 183 for (int i = 0; i < remaining; i++) {
184 __ push(ip); 184 __ push(ip);
185 } 185 }
186 } 186 }
187 } 187 }
188 188
189 bool function_in_register = true; 189 bool function_in_register_r4 = true;
190 190
191 // Possibly allocate a local context. 191 // Possibly allocate a local context.
192 if (info->scope()->num_heap_slots() > 0) { 192 if (info->scope()->num_heap_slots() > 0) {
193 // Argument to NewContext is the function, which is still in r4. 193 // Argument to NewContext is the function, which is still in r4.
194 Comment cmnt(masm_, "[ Allocate context"); 194 Comment cmnt(masm_, "[ Allocate context");
195 bool need_write_barrier = true; 195 bool need_write_barrier = true;
196 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 196 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
197 if (info->scope()->is_script_scope()) { 197 if (info->scope()->is_script_scope()) {
198 __ push(r4); 198 __ push(r4);
199 __ Push(info->scope()->GetScopeInfo(info->isolate())); 199 __ Push(info->scope()->GetScopeInfo(info->isolate()));
200 __ CallRuntime(Runtime::kNewScriptContext, 2); 200 __ CallRuntime(Runtime::kNewScriptContext, 2);
201 } else if (slots <= FastNewContextStub::kMaximumSlots) { 201 } else if (slots <= FastNewContextStub::kMaximumSlots) {
202 FastNewContextStub stub(isolate(), slots); 202 FastNewContextStub stub(isolate(), slots);
203 __ CallStub(&stub); 203 __ CallStub(&stub);
204 // Result of FastNewContextStub is always in new space. 204 // Result of FastNewContextStub is always in new space.
205 need_write_barrier = false; 205 need_write_barrier = false;
206 } else { 206 } else {
207 __ push(r4); 207 __ push(r4);
208 __ CallRuntime(Runtime::kNewFunctionContext, 1); 208 __ CallRuntime(Runtime::kNewFunctionContext, 1);
209 } 209 }
210 function_in_register = false; 210 function_in_register_r4 = false;
211 // Context is returned in r3. It replaces the context passed to us. 211 // Context is returned in r3. It replaces the context passed to us.
212 // It's saved in the stack and kept live in cp. 212 // It's saved in the stack and kept live in cp.
213 __ mr(cp, r3); 213 __ mr(cp, r3);
214 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); 214 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset));
215 // Copy any necessary parameters into the context. 215 // Copy any necessary parameters into the context.
216 int num_parameters = info->scope()->num_parameters(); 216 int num_parameters = info->scope()->num_parameters();
217 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; 217 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0;
218 for (int i = first_parameter; i < num_parameters; i++) { 218 for (int i = first_parameter; i < num_parameters; i++) {
219 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); 219 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
220 if (var->IsContextSlot()) { 220 if (var->IsContextSlot()) {
(...skipping 12 matching lines...) Expand all
233 } else if (FLAG_debug_code) { 233 } else if (FLAG_debug_code) {
234 Label done; 234 Label done;
235 __ JumpIfInNewSpace(cp, r3, &done); 235 __ JumpIfInNewSpace(cp, r3, &done);
236 __ Abort(kExpectedNewSpaceObject); 236 __ Abort(kExpectedNewSpaceObject);
237 __ bind(&done); 237 __ bind(&done);
238 } 238 }
239 } 239 }
240 } 240 }
241 } 241 }
242 242
243 PrepareForBailoutForId(BailoutId::Prologue(), NO_REGISTERS);
244 // Function register is trashed in case we bailout here. But since that
245 // could happen only when we allocate a context the value of
246 // |function_in_register_r4| is correct.
247
243 // Possibly set up a local binding to the this function which is used in 248 // Possibly set up a local binding to the this function which is used in
244 // derived constructors with super calls. 249 // derived constructors with super calls.
245 Variable* this_function_var = scope()->this_function_var(); 250 Variable* this_function_var = scope()->this_function_var();
246 if (this_function_var != nullptr) { 251 if (this_function_var != nullptr) {
247 Comment cmnt(masm_, "[ This function"); 252 Comment cmnt(masm_, "[ This function");
248 if (!function_in_register) { 253 if (!function_in_register_r4) {
249 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 254 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
250 // The write barrier clobbers register again, keep is marked as such. 255 // The write barrier clobbers register again, keep it marked as such.
251 } 256 }
252 SetVar(this_function_var, r4, r3, r5); 257 SetVar(this_function_var, r4, r3, r5);
253 } 258 }
254 259
255 Variable* new_target_var = scope()->new_target_var(); 260 Variable* new_target_var = scope()->new_target_var();
256 if (new_target_var != nullptr) { 261 if (new_target_var != nullptr) {
257 Comment cmnt(masm_, "[ new.target"); 262 Comment cmnt(masm_, "[ new.target");
258 263
259 // Get the frame pointer for the calling frame. 264 // Get the frame pointer for the calling frame.
260 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 265 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
261 266
262 // Skip the arguments adaptor frame if it exists. 267 // Skip the arguments adaptor frame if it exists.
263 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kContextOffset)); 268 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kContextOffset));
264 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); 269 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
265 Label skip; 270 Label skip;
266 __ bne(&skip); 271 __ bne(&skip);
267 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); 272 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset));
268 __ bind(&skip); 273 __ bind(&skip);
269 274
270 // Check the marker in the calling frame. 275 // Check the marker in the calling frame.
271 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kMarkerOffset)); 276 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kMarkerOffset));
272 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::CONSTRUCT), r0); 277 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::CONSTRUCT), r0);
273 Label non_construct_frame, done; 278 Label non_construct_frame, done;
279 function_in_register_r4 = false;
274 280
275 __ bne(&non_construct_frame); 281 __ bne(&non_construct_frame);
276 __ LoadP(r3, MemOperand( 282 __ LoadP(r3, MemOperand(
277 r5, ConstructFrameConstants::kOriginalConstructorOffset)); 283 r5, ConstructFrameConstants::kOriginalConstructorOffset));
278 __ b(&done); 284 __ b(&done);
279 285
280 __ bind(&non_construct_frame); 286 __ bind(&non_construct_frame);
281 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); 287 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
282 __ bind(&done); 288 __ bind(&done);
283 289
284 SetVar(new_target_var, r3, r5, r6); 290 SetVar(new_target_var, r3, r5, r6);
285 } 291 }
286 292
287 // Possibly allocate RestParameters 293 // Possibly allocate RestParameters
288 int rest_index; 294 int rest_index;
289 Variable* rest_param = scope()->rest_parameter(&rest_index); 295 Variable* rest_param = scope()->rest_parameter(&rest_index);
290 if (rest_param) { 296 if (rest_param) {
291 Comment cmnt(masm_, "[ Allocate rest parameter array"); 297 Comment cmnt(masm_, "[ Allocate rest parameter array");
292 298
293 int num_parameters = info->scope()->num_parameters(); 299 int num_parameters = info->scope()->num_parameters();
294 int offset = num_parameters * kPointerSize; 300 int offset = num_parameters * kPointerSize;
295 301
296 __ addi(r6, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset)); 302 __ addi(r6, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset));
297 __ LoadSmiLiteral(r5, Smi::FromInt(num_parameters)); 303 __ LoadSmiLiteral(r5, Smi::FromInt(num_parameters));
298 __ LoadSmiLiteral(r4, Smi::FromInt(rest_index)); 304 __ LoadSmiLiteral(r4, Smi::FromInt(rest_index));
299 __ LoadSmiLiteral(r3, Smi::FromInt(language_mode())); 305 __ LoadSmiLiteral(r3, Smi::FromInt(language_mode()));
300 __ Push(r6, r5, r4, r3); 306 __ Push(r6, r5, r4, r3);
307 function_in_register_r4 = false;
301 308
302 RestParamAccessStub stub(isolate()); 309 RestParamAccessStub stub(isolate());
303 __ CallStub(&stub); 310 __ CallStub(&stub);
304 311
305 SetVar(rest_param, r3, r4, r5); 312 SetVar(rest_param, r3, r4, r5);
306 } 313 }
307 314
308 Variable* arguments = scope()->arguments(); 315 Variable* arguments = scope()->arguments();
309 if (arguments != NULL) { 316 if (arguments != NULL) {
310 // Function uses arguments object. 317 // Function uses arguments object.
311 Comment cmnt(masm_, "[ Allocate arguments object"); 318 Comment cmnt(masm_, "[ Allocate arguments object");
312 if (!function_in_register) { 319 if (!function_in_register_r4) {
313 // Load this again, if it's used by the local context below. 320 // Load this again, if it's used by the local context below.
314 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 321 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
315 } else { 322 } else {
316 __ mr(r6, r4); 323 __ mr(r6, r4);
317 } 324 }
318 // Receiver is just before the parameters on the caller's stack. 325 // Receiver is just before the parameters on the caller's stack.
319 int num_parameters = info->scope()->num_parameters(); 326 int num_parameters = info->scope()->num_parameters();
320 int offset = num_parameters * kPointerSize; 327 int offset = num_parameters * kPointerSize;
321 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset)); 328 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset));
322 __ LoadSmiLiteral(r4, Smi::FromInt(num_parameters)); 329 __ LoadSmiLiteral(r4, Smi::FromInt(num_parameters));
(...skipping 4992 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 return ON_STACK_REPLACEMENT; 5322 return ON_STACK_REPLACEMENT;
5316 } 5323 }
5317 5324
5318 DCHECK(interrupt_address == 5325 DCHECK(interrupt_address ==
5319 isolate->builtins()->OsrAfterStackCheck()->entry()); 5326 isolate->builtins()->OsrAfterStackCheck()->entry());
5320 return OSR_AFTER_STACK_CHECK; 5327 return OSR_AFTER_STACK_CHECK;
5321 } 5328 }
5322 } // namespace internal 5329 } // namespace internal
5323 } // namespace v8 5330 } // namespace v8
5324 #endif // V8_TARGET_ARCH_PPC 5331 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | src/ppc/lithium-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698