| 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 Isolate* isolate = masm->isolate(); | 338 Isolate* isolate = masm->isolate(); |
| 339 | 339 |
| 340 // Enter a construct frame. | 340 // Enter a construct frame. |
| 341 { | 341 { |
| 342 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 342 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
| 343 | 343 |
| 344 // Preserve the incoming parameters on the stack. | 344 // Preserve the incoming parameters on the stack. |
| 345 __ AssertUndefinedOrAllocationSite(r5, r7); | 345 __ AssertUndefinedOrAllocationSite(r5, r7); |
| 346 | 346 |
| 347 if (!create_implicit_receiver) { | 347 if (!create_implicit_receiver) { |
| 348 // Push new.target onto the construct frame. This is stored just below the | |
| 349 // receiver on the stack. | |
| 350 __ SmiTag(r7, r3, SetRC); | 348 __ SmiTag(r7, r3, SetRC); |
| 351 __ Push(r5, r7, r6); | 349 __ Push(r5, r7); |
| 352 __ PushRoot(Heap::kTheHoleValueRootIndex); | 350 __ PushRoot(Heap::kTheHoleValueRootIndex); |
| 353 } else { | 351 } else { |
| 354 __ SmiTag(r3); | 352 __ SmiTag(r3); |
| 355 __ Push(r5, r3); | 353 __ Push(r5, r3); |
| 356 | 354 |
| 357 // Try to allocate the object without transitioning into C code. If any of | 355 // Try to allocate the object without transitioning into C code. If any of |
| 358 // the preconditions is not met, the code bails out to the runtime call. | 356 // the preconditions is not met, the code bails out to the runtime call. |
| 359 Label rt_call, allocated; | 357 Label rt_call, allocated; |
| 360 if (FLAG_inline_new) { | 358 if (FLAG_inline_new) { |
| 361 // Verify that the new target is a JSFunction. | 359 // Verify that the new target is a JSFunction. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // Receiver for constructor call allocated. | 489 // Receiver for constructor call allocated. |
| 492 // r4: constructor function | 490 // r4: constructor function |
| 493 // r6: new target | 491 // r6: new target |
| 494 // r7: JSObject | 492 // r7: JSObject |
| 495 __ bind(&allocated); | 493 __ bind(&allocated); |
| 496 | 494 |
| 497 // Retrieve smi-tagged arguments count from the stack. | 495 // Retrieve smi-tagged arguments count from the stack. |
| 498 __ LoadP(r3, MemOperand(sp)); | 496 __ LoadP(r3, MemOperand(sp)); |
| 499 __ SmiUntag(r3, SetRC); | 497 __ SmiUntag(r3, SetRC); |
| 500 | 498 |
| 501 // Push new.target onto the construct frame. This is stored just below the | |
| 502 // receiver on the stack. | |
| 503 // Push the allocated receiver to the stack. We need two copies | 499 // Push the allocated receiver to the stack. We need two copies |
| 504 // because we may have to return the original one and the calling | 500 // because we may have to return the original one and the calling |
| 505 // conventions dictate that the called function pops the receiver. | 501 // conventions dictate that the called function pops the receiver. |
| 506 __ Push(r6, r7, r7); | 502 __ Push(r7, r7); |
| 507 } | 503 } |
| 508 | 504 |
| 509 // Set up pointer to last argument. | 505 // Set up pointer to last argument. |
| 510 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset)); | 506 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 511 | 507 |
| 512 // Copy arguments and receiver to the expression stack. | 508 // Copy arguments and receiver to the expression stack. |
| 513 // r3: number of arguments | 509 // r3: number of arguments |
| 514 // r4: constructor function | 510 // r4: constructor function |
| 515 // r5: address of last argument (caller sp) | 511 // r5: address of last argument (caller sp) |
| 516 // r6: new target | 512 // r6: new target |
| 517 // cr0: condition indicating whether r3 is zero | 513 // cr0: condition indicating whether r3 is zero |
| 518 // sp[0]: receiver | 514 // sp[0]: receiver |
| 519 // sp[1]: receiver | 515 // sp[1]: receiver |
| 520 // sp[2]: new.target | 516 // sp[2]: number of arguments (smi-tagged) |
| 521 // sp[3]: number of arguments (smi-tagged) | |
| 522 Label loop, no_args; | 517 Label loop, no_args; |
| 523 __ beq(&no_args, cr0); | 518 __ beq(&no_args, cr0); |
| 524 __ ShiftLeftImm(ip, r3, Operand(kPointerSizeLog2)); | 519 __ ShiftLeftImm(ip, r3, Operand(kPointerSizeLog2)); |
| 525 __ sub(sp, sp, ip); | 520 __ sub(sp, sp, ip); |
| 526 __ mtctr(r3); | 521 __ mtctr(r3); |
| 527 __ bind(&loop); | 522 __ bind(&loop); |
| 528 __ subi(ip, ip, Operand(kPointerSize)); | 523 __ subi(ip, ip, Operand(kPointerSize)); |
| 529 __ LoadPX(r0, MemOperand(r5, ip)); | 524 __ LoadPX(r0, MemOperand(r5, ip)); |
| 530 __ StorePX(r0, MemOperand(sp, ip)); | 525 __ StorePX(r0, MemOperand(sp, ip)); |
| 531 __ bdnz(&loop); | 526 __ bdnz(&loop); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 546 } | 541 } |
| 547 | 542 |
| 548 // Store offset of return address for deoptimizer. | 543 // Store offset of return address for deoptimizer. |
| 549 if (create_implicit_receiver && !is_api_function) { | 544 if (create_implicit_receiver && !is_api_function) { |
| 550 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 545 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
| 551 } | 546 } |
| 552 | 547 |
| 553 // Restore context from the frame. | 548 // Restore context from the frame. |
| 554 // r3: result | 549 // r3: result |
| 555 // sp[0]: receiver | 550 // sp[0]: receiver |
| 556 // sp[1]: new.target | 551 // sp[1]: number of arguments (smi-tagged) |
| 557 // sp[2]: number of arguments (smi-tagged) | |
| 558 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 552 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 559 | 553 |
| 560 if (create_implicit_receiver) { | 554 if (create_implicit_receiver) { |
| 561 // If the result is an object (in the ECMA sense), we should get rid | 555 // If the result is an object (in the ECMA sense), we should get rid |
| 562 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 556 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
| 563 // on page 74. | 557 // on page 74. |
| 564 Label use_receiver, exit; | 558 Label use_receiver, exit; |
| 565 | 559 |
| 566 // If the result is a smi, it is *not* an object in the ECMA sense. | 560 // If the result is a smi, it is *not* an object in the ECMA sense. |
| 567 // r3: result | 561 // r3: result |
| 568 // sp[0]: receiver | 562 // sp[0]: receiver |
| 569 // sp[1]: new.target | 563 // sp[1]: number of arguments (smi-tagged) |
| 570 // sp[2]: number of arguments (smi-tagged) | |
| 571 __ JumpIfSmi(r3, &use_receiver); | 564 __ JumpIfSmi(r3, &use_receiver); |
| 572 | 565 |
| 573 // If the type of the result (stored in its map) is less than | 566 // If the type of the result (stored in its map) is less than |
| 574 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. | 567 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. |
| 575 __ CompareObjectType(r3, r4, r6, FIRST_JS_RECEIVER_TYPE); | 568 __ CompareObjectType(r3, r4, r6, FIRST_JS_RECEIVER_TYPE); |
| 576 __ bge(&exit); | 569 __ bge(&exit); |
| 577 | 570 |
| 578 // Throw away the result of the constructor invocation and use the | 571 // Throw away the result of the constructor invocation and use the |
| 579 // on-stack receiver as the result. | 572 // on-stack receiver as the result. |
| 580 __ bind(&use_receiver); | 573 __ bind(&use_receiver); |
| 581 __ LoadP(r3, MemOperand(sp)); | 574 __ LoadP(r3, MemOperand(sp)); |
| 582 | 575 |
| 583 // Remove receiver from the stack, remove caller arguments, and | 576 // Remove receiver from the stack, remove caller arguments, and |
| 584 // return. | 577 // return. |
| 585 __ bind(&exit); | 578 __ bind(&exit); |
| 586 // r3: result | 579 // r3: result |
| 587 // sp[0]: receiver (newly allocated object) | 580 // sp[0]: receiver (newly allocated object) |
| 588 // sp[1]: new.target (new target) | 581 // sp[1]: number of arguments (smi-tagged) |
| 589 // sp[2]: number of arguments (smi-tagged) | 582 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); |
| 590 __ LoadP(r4, MemOperand(sp, 2 * kPointerSize)); | |
| 591 } else { | 583 } else { |
| 592 __ LoadP(r4, MemOperand(sp, kPointerSize)); | 584 __ LoadP(r4, MemOperand(sp)); |
| 593 } | 585 } |
| 594 | 586 |
| 595 // Leave construct frame. | 587 // Leave construct frame. |
| 596 } | 588 } |
| 597 | 589 |
| 598 __ SmiToPtrArrayOffset(r4, r4); | 590 __ SmiToPtrArrayOffset(r4, r4); |
| 599 __ add(sp, sp, r4); | 591 __ add(sp, sp, r4); |
| 600 __ addi(sp, sp, Operand(kPointerSize)); | 592 __ addi(sp, sp, Operand(kPointerSize)); |
| 601 if (create_implicit_receiver) { | 593 if (create_implicit_receiver) { |
| 602 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); | 594 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 __ bkpt(0); | 1972 __ bkpt(0); |
| 1981 } | 1973 } |
| 1982 } | 1974 } |
| 1983 | 1975 |
| 1984 | 1976 |
| 1985 #undef __ | 1977 #undef __ |
| 1986 } // namespace internal | 1978 } // namespace internal |
| 1987 } // namespace v8 | 1979 } // namespace v8 |
| 1988 | 1980 |
| 1989 #endif // V8_TARGET_ARCH_PPC | 1981 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |