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

Side by Side Diff: src/mips64/builtins-mips64.cc

Issue 1227163011: Cleanup Generate_JSConstructStubHelper a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment typo. Created 5 years, 5 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 | « src/mips/builtins-mips.cc ('k') | src/x64/builtins-x64.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 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 5
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_MIPS64 9 #if V8_TARGET_ARCH_MIPS64
10 10
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 __ Branch(&ok, hs, sp, Operand(a4)); 308 __ Branch(&ok, hs, sp, Operand(a4));
309 309
310 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); 310 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
311 GenerateTailCallToReturnedCode(masm); 311 GenerateTailCallToReturnedCode(masm);
312 312
313 __ bind(&ok); 313 __ bind(&ok);
314 GenerateTailCallToSharedCode(masm); 314 GenerateTailCallToSharedCode(masm);
315 } 315 }
316 316
317 317
318 static void Generate_Runtime_NewObject(MacroAssembler* masm,
319 bool create_memento,
320 Register original_constructor,
321 Label* count_incremented,
322 Label* allocated) {
323 if (create_memento) {
324 // Get the cell or allocation site.
325 __ ld(a2, MemOperand(sp, 3 * kPointerSize));
326 __ push(a2);
327 }
328
329 __ push(a1); // argument for Runtime_NewObject
330 __ push(original_constructor); // original constructor
331 if (create_memento) {
332 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
333 } else {
334 __ CallRuntime(Runtime::kNewObject, 2);
335 }
336 __ mov(t0, v0);
337
338 // Runtime_NewObjectWithAllocationSite increments allocation count.
339 // Skip the increment.
340 if (create_memento) {
341 __ jmp(count_incremented);
342 } else {
343 __ jmp(allocated);
344 }
345 }
346
347
348 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 318 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
349 bool is_api_function, 319 bool is_api_function,
350 bool create_memento) { 320 bool create_memento) {
351 // ----------- S t a t e ------------- 321 // ----------- S t a t e -------------
352 // -- a0 : number of arguments 322 // -- a0 : number of arguments
353 // -- a1 : constructor function 323 // -- a1 : constructor function
354 // -- a2 : allocation site or undefined 324 // -- a2 : allocation site or undefined
355 // -- a3 : original constructor 325 // -- a3 : original constructor
356 // -- ra : return address 326 // -- ra : return address
357 // -- sp[...]: constructor arguments 327 // -- sp[...]: constructor arguments
358 // ----------------------------------- 328 // -----------------------------------
359 329
360 // Should never create mementos for api functions. 330 // Should never create mementos for api functions.
361 DCHECK(!is_api_function || !create_memento); 331 DCHECK(!is_api_function || !create_memento);
362 332
363 Isolate* isolate = masm->isolate(); 333 Isolate* isolate = masm->isolate();
364 334
365 // ----------- S t a t e -------------
366 // -- a0 : number of arguments
367 // -- a1 : constructor function
368 // -- ra : return address
369 // -- sp[...]: constructor arguments
370 // -----------------------------------
371
372 // Enter a construct frame. 335 // Enter a construct frame.
373 { 336 {
374 FrameScope scope(masm, StackFrame::CONSTRUCT); 337 FrameScope scope(masm, StackFrame::CONSTRUCT);
375 338
376 if (create_memento) { 339 if (create_memento) {
377 __ AssertUndefinedOrAllocationSite(a2, t0); 340 __ AssertUndefinedOrAllocationSite(a2, t0);
378 __ push(a2); 341 __ push(a2);
379 } 342 }
380 343
381 // Preserve the incoming parameters on the stack. 344 // Preserve the incoming parameters on the stack.
382 __ SmiTag(a0); 345 __ SmiTag(a0);
383 __ Push(a0, a1, a3); 346 __ Push(a0, a1, a3);
384 347
385 Label rt_call, allocated, normal_new, count_incremented;
386 __ Branch(&normal_new, eq, a1, Operand(a3));
387
388 // Original constructor and function are different.
389 Generate_Runtime_NewObject(masm, create_memento, a3, &count_incremented,
390 &allocated);
391 __ bind(&normal_new);
392
393 // Try to allocate the object without transitioning into C code. If any of 348 // Try to allocate the object without transitioning into C code. If any of
394 // the preconditions is not met, the code bails out to the runtime call. 349 // the preconditions is not met, the code bails out to the runtime call.
350 Label rt_call, allocated;
395 if (FLAG_inline_new) { 351 if (FLAG_inline_new) {
396 ExternalReference debug_step_in_fp = 352 ExternalReference debug_step_in_fp =
397 ExternalReference::debug_step_in_fp_address(isolate); 353 ExternalReference::debug_step_in_fp_address(isolate);
398 __ li(a2, Operand(debug_step_in_fp)); 354 __ li(a2, Operand(debug_step_in_fp));
399 __ ld(a2, MemOperand(a2)); 355 __ ld(a2, MemOperand(a2));
400 __ Branch(&rt_call, ne, a2, Operand(zero_reg)); 356 __ Branch(&rt_call, ne, a2, Operand(zero_reg));
401 357
358 // Fall back to runtime if the original constructor and function differ.
359 __ Branch(&rt_call, ne, a1, Operand(a3));
360
402 // Load the initial map and verify that it is in fact a map. 361 // Load the initial map and verify that it is in fact a map.
403 // a1: constructor function 362 // a1: constructor function
404 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); 363 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
405 __ JumpIfSmi(a2, &rt_call); 364 __ JumpIfSmi(a2, &rt_call);
406 __ GetObjectType(a2, a3, t0); 365 __ GetObjectType(a2, t1, t0);
407 __ Branch(&rt_call, ne, t0, Operand(MAP_TYPE)); 366 __ Branch(&rt_call, ne, t0, Operand(MAP_TYPE));
408 367
409 // Check that the constructor is not constructing a JSFunction (see 368 // Check that the constructor is not constructing a JSFunction (see
410 // comments in Runtime_NewObject in runtime.cc). In which case the 369 // comments in Runtime_NewObject in runtime.cc). In which case the
411 // initial map's instance type would be JS_FUNCTION_TYPE. 370 // initial map's instance type would be JS_FUNCTION_TYPE.
412 // a1: constructor function 371 // a1: constructor function
413 // a2: initial map 372 // a2: initial map
414 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset)); 373 __ lbu(t1, FieldMemOperand(a2, Map::kInstanceTypeOffset));
415 __ Branch(&rt_call, eq, a3, Operand(JS_FUNCTION_TYPE)); 374 __ Branch(&rt_call, eq, t1, Operand(JS_FUNCTION_TYPE));
416 375
417 if (!is_api_function) { 376 if (!is_api_function) {
418 Label allocate; 377 Label allocate;
419 MemOperand bit_field3 = FieldMemOperand(a2, Map::kBitField3Offset); 378 MemOperand bit_field3 = FieldMemOperand(a2, Map::kBitField3Offset);
420 // Check if slack tracking is enabled. 379 // Check if slack tracking is enabled.
421 __ lwu(a4, bit_field3); 380 __ lwu(a4, bit_field3);
422 __ DecodeField<Map::Counter>(a6, a4); 381 __ DecodeField<Map::Counter>(a6, a4);
423 __ Branch(&allocate, lt, a6, 382 __ Branch(&allocate, lt, a6,
424 Operand(static_cast<int64_t>(Map::kSlackTrackingCounterEnd))); 383 Operand(static_cast<int64_t>(Map::kSlackTrackingCounterEnd)));
425 // Decrease generous allocation count. 384 // Decrease generous allocation count.
426 __ Dsubu(a4, a4, Operand(1 << Map::Counter::kShift)); 385 __ Dsubu(a4, a4, Operand(1 << Map::Counter::kShift));
427 __ Branch(USE_DELAY_SLOT, &allocate, ne, a6, 386 __ Branch(USE_DELAY_SLOT, &allocate, ne, a6,
428 Operand(Map::kSlackTrackingCounterEnd)); 387 Operand(Map::kSlackTrackingCounterEnd));
429 __ sw(a4, bit_field3); // In delay slot. 388 __ sw(a4, bit_field3); // In delay slot.
430 389
431 __ Push(a1, a2, a1); // a1 = Constructor. 390 __ Push(a1, a2, a1); // a1 = Constructor.
432 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); 391 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
433 392
434 __ Pop(a1, a2); 393 __ Pop(a1, a2);
435 __ li(a6, Operand(Map::kSlackTrackingCounterEnd - 1)); 394 __ li(a6, Operand(Map::kSlackTrackingCounterEnd - 1));
436 395
437 __ bind(&allocate); 396 __ bind(&allocate);
438 } 397 }
439 398
440 // Now allocate the JSObject on the heap. 399 // Now allocate the JSObject on the heap.
441 // a1: constructor function 400 // a1: constructor function
442 // a2: initial map 401 // a2: initial map
402 Label rt_call_reload_new_target;
443 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); 403 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset));
444 if (create_memento) { 404 if (create_memento) {
445 __ Daddu(a3, a3, Operand(AllocationMemento::kSize / kPointerSize)); 405 __ Daddu(a3, a3, Operand(AllocationMemento::kSize / kPointerSize));
446 } 406 }
447 407
448 __ Allocate(a3, t0, t1, t2, &rt_call, SIZE_IN_WORDS); 408 __ Allocate(a3, t0, t1, t2, &rt_call_reload_new_target, SIZE_IN_WORDS);
449 409
450 // Allocated the JSObject, now initialize the fields. Map is set to 410 // Allocated the JSObject, now initialize the fields. Map is set to
451 // initial map and properties and elements are set to empty fixed array. 411 // initial map and properties and elements are set to empty fixed array.
452 // a1: constructor function 412 // a1: constructor function
453 // a2: initial map 413 // a2: initial map
454 // a3: object size (including memento if create_memento) 414 // a3: object size (including memento if create_memento)
455 // t0: JSObject (not tagged) 415 // t0: JSObject (not tagged)
456 __ LoadRoot(t2, Heap::kEmptyFixedArrayRootIndex); 416 __ LoadRoot(t2, Heap::kEmptyFixedArrayRootIndex);
457 __ mov(t1, t0); 417 __ mov(t1, t0);
458 __ sd(a2, MemOperand(t1, JSObject::kMapOffset)); 418 __ sd(a2, MemOperand(t1, JSObject::kMapOffset));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 __ InitializeFieldsWithFiller(t1, a0, t3); 490 __ InitializeFieldsWithFiller(t1, a0, t3);
531 } 491 }
532 492
533 // Add the object tag to make the JSObject real, so that we can continue 493 // Add the object tag to make the JSObject real, so that we can continue
534 // and jump into the continuation code at any time from now on. 494 // and jump into the continuation code at any time from now on.
535 __ Daddu(t0, t0, Operand(kHeapObjectTag)); 495 __ Daddu(t0, t0, Operand(kHeapObjectTag));
536 496
537 // Continue with JSObject being successfully allocated. 497 // Continue with JSObject being successfully allocated.
538 // a4: JSObject 498 // a4: JSObject
539 __ jmp(&allocated); 499 __ jmp(&allocated);
500
501 // Reload the original constructor and fall-through.
502 __ bind(&rt_call_reload_new_target);
503 __ ld(a3, MemOperand(sp, 0 * kPointerSize));
540 } 504 }
541 505
542 // Allocate the new receiver object using the runtime call. 506 // Allocate the new receiver object using the runtime call.
543 // a1: constructor function 507 // a1: constructor function
508 // a3: original constructor
544 __ bind(&rt_call); 509 __ bind(&rt_call);
545 Generate_Runtime_NewObject(masm, create_memento, a1, &count_incremented, 510 if (create_memento) {
546 &allocated); 511 // Get the cell or allocation site.
512 __ ld(a2, MemOperand(sp, 3 * kPointerSize));
513 __ push(a2); // argument 1: allocation site
514 }
547 515
516 __ Push(a1, a3); // arguments 2-3 / 1-2
517 if (create_memento) {
518 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
519 } else {
520 __ CallRuntime(Runtime::kNewObject, 2);
521 }
522 __ mov(t0, v0);
523
524 // Runtime_NewObjectWithAllocationSite increments allocation count.
525 // Skip the increment.
526 Label count_incremented;
527 if (create_memento) {
528 __ jmp(&count_incremented);
529 }
548 530
549 // Receiver for constructor call allocated. 531 // Receiver for constructor call allocated.
550 // t0: JSObject 532 // t0: JSObject
551 __ bind(&allocated); 533 __ bind(&allocated);
552 534
553 if (create_memento) { 535 if (create_memento) {
554 __ ld(a2, MemOperand(sp, 3 * kPointerSize)); 536 __ ld(a2, MemOperand(sp, 3 * kPointerSize));
555 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex); 537 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex);
556 __ Branch(&count_incremented, eq, a2, Operand(t1)); 538 __ Branch(&count_incremented, eq, a2, Operand(t1));
557 // a2 is an AllocationSite. We are creating a memento from it, so we 539 // a2 is an AllocationSite. We are creating a memento from it, so we
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 } 1740 }
1759 } 1741 }
1760 1742
1761 1743
1762 #undef __ 1744 #undef __
1763 1745
1764 } // namespace internal 1746 } // namespace internal
1765 } // namespace v8 1747 } // namespace v8
1766 1748
1767 #endif // V8_TARGET_ARCH_MIPS64 1749 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698