OLD | NEW |
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 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 int32_t sp_delta = arg_count * kPointerSize; | 452 int32_t sp_delta = arg_count * kPointerSize; |
453 SetReturnPosition(literal()); | 453 SetReturnPosition(literal()); |
454 masm_->mov(sp, fp); | 454 masm_->mov(sp, fp); |
455 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); | 455 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); |
456 masm_->Addu(sp, sp, Operand(sp_delta)); | 456 masm_->Addu(sp, sp, Operand(sp_delta)); |
457 masm_->Jump(ra); | 457 masm_->Jump(ra); |
458 } | 458 } |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
| 462 void FullCodeGenerator::RestoreContext() { |
| 463 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 464 } |
462 | 465 |
463 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { | 466 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
464 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 467 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
465 codegen()->GetVar(result_register(), var); | 468 codegen()->GetVar(result_register(), var); |
466 codegen()->PushOperand(result_register()); | 469 codegen()->PushOperand(result_register()); |
467 } | 470 } |
468 | 471 |
469 | 472 |
470 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { | 473 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { |
471 } | 474 } |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1409 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1407 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1410 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1408 __ li(a1, Operand(constant_properties)); | 1411 __ li(a1, Operand(constant_properties)); |
1409 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); | 1412 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); |
1410 if (MustCreateObjectLiteralWithRuntime(expr)) { | 1413 if (MustCreateObjectLiteralWithRuntime(expr)) { |
1411 __ Push(a3, a2, a1, a0); | 1414 __ Push(a3, a2, a1, a0); |
1412 __ CallRuntime(Runtime::kCreateObjectLiteral); | 1415 __ CallRuntime(Runtime::kCreateObjectLiteral); |
1413 } else { | 1416 } else { |
1414 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); | 1417 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
1415 __ CallStub(&stub); | 1418 __ CallStub(&stub); |
1416 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1419 RestoreContext(); |
1417 } | 1420 } |
1418 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1421 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1419 | 1422 |
1420 // If result_saved is true the result is on top of the stack. If | 1423 // If result_saved is true the result is on top of the stack. If |
1421 // result_saved is false the result is in v0. | 1424 // result_saved is false the result is in v0. |
1422 bool result_saved = false; | 1425 bool result_saved = false; |
1423 | 1426 |
1424 AccessorTable accessor_table(zone()); | 1427 AccessorTable accessor_table(zone()); |
1425 int property_index = 0; | 1428 int property_index = 0; |
1426 for (; property_index < expr->properties()->length(); property_index++) { | 1429 for (; property_index < expr->properties()->length(); property_index++) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); | 1855 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); |
1853 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); | 1856 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); |
1854 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); | 1857 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); |
1855 __ mov(a1, cp); | 1858 __ mov(a1, cp); |
1856 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, | 1859 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, |
1857 kRAHasBeenSaved, kDontSaveFPRegs); | 1860 kRAHasBeenSaved, kDontSaveFPRegs); |
1858 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1861 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1859 __ Branch(&post_runtime, eq, sp, Operand(a1)); | 1862 __ Branch(&post_runtime, eq, sp, Operand(a1)); |
1860 __ push(v0); // generator object | 1863 __ push(v0); // generator object |
1861 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1864 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1862 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1865 RestoreContext(); |
1863 __ bind(&post_runtime); | 1866 __ bind(&post_runtime); |
1864 PopOperand(result_register()); | 1867 PopOperand(result_register()); |
1865 EmitReturnSequence(); | 1868 EmitReturnSequence(); |
1866 | 1869 |
1867 __ bind(&resume); | 1870 __ bind(&resume); |
1868 context()->Plug(result_register()); | 1871 context()->Plug(result_register()); |
1869 } | 1872 } |
1870 | 1873 |
1871 void FullCodeGenerator::PushOperands(Register reg1, Register reg2) { | 1874 void FullCodeGenerator::PushOperands(Register reg1, Register reg2) { |
1872 OperandStackDepthIncrement(2); | 1875 OperandStackDepthIncrement(2); |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) | 2528 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) |
2526 .code(); | 2529 .code(); |
2527 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); | 2530 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); |
2528 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2531 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2529 // Don't assign a type feedback id to the IC, since type feedback is provided | 2532 // Don't assign a type feedback id to the IC, since type feedback is provided |
2530 // by the vector above. | 2533 // by the vector above. |
2531 CallIC(ic); | 2534 CallIC(ic); |
2532 OperandStackDepthDecrement(arg_count + 1); | 2535 OperandStackDepthDecrement(arg_count + 1); |
2533 | 2536 |
2534 RecordJSReturnSite(expr); | 2537 RecordJSReturnSite(expr); |
2535 // Restore context register. | 2538 RestoreContext(); |
2536 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2537 context()->DropAndPlug(1, v0); | 2539 context()->DropAndPlug(1, v0); |
2538 } | 2540 } |
2539 | 2541 |
2540 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { | 2542 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { |
2541 int arg_count = expr->arguments()->length(); | 2543 int arg_count = expr->arguments()->length(); |
2542 // t4: copy of the first argument or undefined if it doesn't exist. | 2544 // t4: copy of the first argument or undefined if it doesn't exist. |
2543 if (arg_count > 0) { | 2545 if (arg_count > 0) { |
2544 __ lw(t4, MemOperand(sp, arg_count * kPointerSize)); | 2546 __ lw(t4, MemOperand(sp, arg_count * kPointerSize)); |
2545 } else { | 2547 } else { |
2546 __ LoadRoot(t4, Heap::kUndefinedValueRootIndex); | 2548 __ LoadRoot(t4, Heap::kUndefinedValueRootIndex); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2634 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
2633 // Record source position for debugger. | 2635 // Record source position for debugger. |
2634 SetCallPosition(expr); | 2636 SetCallPosition(expr); |
2635 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2637 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2636 __ li(a0, Operand(arg_count)); | 2638 __ li(a0, Operand(arg_count)); |
2637 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2639 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
2638 expr->tail_call_mode()), | 2640 expr->tail_call_mode()), |
2639 RelocInfo::CODE_TARGET); | 2641 RelocInfo::CODE_TARGET); |
2640 OperandStackDepthDecrement(arg_count + 1); | 2642 OperandStackDepthDecrement(arg_count + 1); |
2641 RecordJSReturnSite(expr); | 2643 RecordJSReturnSite(expr); |
2642 // Restore context register. | 2644 RestoreContext(); |
2643 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2644 context()->DropAndPlug(1, v0); | 2645 context()->DropAndPlug(1, v0); |
2645 } | 2646 } |
2646 | 2647 |
2647 | 2648 |
2648 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2649 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
2649 Comment cmnt(masm_, "[ CallNew"); | 2650 Comment cmnt(masm_, "[ CallNew"); |
2650 // According to ECMA-262, section 11.2.2, page 44, the function | 2651 // According to ECMA-262, section 11.2.2, page 44, the function |
2651 // expression in new calls must be evaluated before the | 2652 // expression in new calls must be evaluated before the |
2652 // arguments. | 2653 // arguments. |
2653 | 2654 |
(...skipping 19 matching lines...) Expand all Loading... |
2673 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); | 2674 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); |
2674 | 2675 |
2675 // Record call targets in unoptimized code. | 2676 // Record call targets in unoptimized code. |
2676 __ EmitLoadTypeFeedbackVector(a2); | 2677 __ EmitLoadTypeFeedbackVector(a2); |
2677 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 2678 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
2678 | 2679 |
2679 CallConstructStub stub(isolate()); | 2680 CallConstructStub stub(isolate()); |
2680 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); | 2681 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); |
2681 OperandStackDepthDecrement(arg_count + 1); | 2682 OperandStackDepthDecrement(arg_count + 1); |
2682 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2683 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
2683 // Restore context register. | 2684 RestoreContext(); |
2684 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2685 context()->Plug(v0); | 2685 context()->Plug(v0); |
2686 } | 2686 } |
2687 | 2687 |
2688 | 2688 |
2689 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2689 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
2690 SuperCallReference* super_call_ref = | 2690 SuperCallReference* super_call_ref = |
2691 expr->expression()->AsSuperCallReference(); | 2691 expr->expression()->AsSuperCallReference(); |
2692 DCHECK_NOT_NULL(super_call_ref); | 2692 DCHECK_NOT_NULL(super_call_ref); |
2693 | 2693 |
2694 // Push the super constructor target on the stack (may be null, | 2694 // Push the super constructor target on the stack (may be null, |
(...skipping 22 matching lines...) Expand all Loading... |
2717 __ mov(a3, result_register()); | 2717 __ mov(a3, result_register()); |
2718 | 2718 |
2719 // Load function and argument count into a1 and a0. | 2719 // Load function and argument count into a1 and a0. |
2720 __ li(a0, Operand(arg_count)); | 2720 __ li(a0, Operand(arg_count)); |
2721 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); | 2721 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); |
2722 | 2722 |
2723 __ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 2723 __ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
2724 OperandStackDepthDecrement(arg_count + 1); | 2724 OperandStackDepthDecrement(arg_count + 1); |
2725 | 2725 |
2726 RecordJSReturnSite(expr); | 2726 RecordJSReturnSite(expr); |
2727 | 2727 RestoreContext(); |
2728 // Restore context register. | |
2729 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2730 context()->Plug(v0); | 2728 context()->Plug(v0); |
2731 } | 2729 } |
2732 | 2730 |
2733 | 2731 |
2734 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2732 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
2735 ZoneList<Expression*>* args = expr->arguments(); | 2733 ZoneList<Expression*>* args = expr->arguments(); |
2736 DCHECK(args->length() == 1); | 2734 DCHECK(args->length() == 1); |
2737 | 2735 |
2738 VisitForAccumulatorValue(args->at(0)); | 2736 VisitForAccumulatorValue(args->at(0)); |
2739 | 2737 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 VisitForStackValue(arg); | 3128 VisitForStackValue(arg); |
3131 } | 3129 } |
3132 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 3130 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
3133 // Move target to a1. | 3131 // Move target to a1. |
3134 int const argc = args->length() - 2; | 3132 int const argc = args->length() - 2; |
3135 __ lw(a1, MemOperand(sp, (argc + 1) * kPointerSize)); | 3133 __ lw(a1, MemOperand(sp, (argc + 1) * kPointerSize)); |
3136 // Call the target. | 3134 // Call the target. |
3137 __ li(a0, Operand(argc)); | 3135 __ li(a0, Operand(argc)); |
3138 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 3136 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
3139 OperandStackDepthDecrement(argc + 1); | 3137 OperandStackDepthDecrement(argc + 1); |
3140 // Restore context register. | 3138 RestoreContext(); |
3141 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
3142 // Discard the function left on TOS. | 3139 // Discard the function left on TOS. |
3143 context()->DropAndPlug(1, v0); | 3140 context()->DropAndPlug(1, v0); |
3144 } | 3141 } |
3145 | 3142 |
3146 | 3143 |
3147 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { | 3144 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { |
3148 ZoneList<Expression*>* args = expr->arguments(); | 3145 ZoneList<Expression*>* args = expr->arguments(); |
3149 VisitForAccumulatorValue(args->at(0)); | 3146 VisitForAccumulatorValue(args->at(0)); |
3150 | 3147 |
3151 Label materialize_true, materialize_false; | 3148 Label materialize_true, materialize_false; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 3245 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
3249 ZoneList<Expression*>* args = expr->arguments(); | 3246 ZoneList<Expression*>* args = expr->arguments(); |
3250 int arg_count = args->length(); | 3247 int arg_count = args->length(); |
3251 | 3248 |
3252 SetCallPosition(expr); | 3249 SetCallPosition(expr); |
3253 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 3250 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
3254 __ li(a0, Operand(arg_count)); | 3251 __ li(a0, Operand(arg_count)); |
3255 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), | 3252 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), |
3256 RelocInfo::CODE_TARGET); | 3253 RelocInfo::CODE_TARGET); |
3257 OperandStackDepthDecrement(arg_count + 1); | 3254 OperandStackDepthDecrement(arg_count + 1); |
3258 | 3255 RestoreContext(); |
3259 // Restore context register. | |
3260 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
3261 } | 3256 } |
3262 | 3257 |
3263 | 3258 |
3264 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 3259 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
3265 switch (expr->op()) { | 3260 switch (expr->op()) { |
3266 case Token::DELETE: { | 3261 case Token::DELETE: { |
3267 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); | 3262 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); |
3268 Property* property = expr->expression()->AsProperty(); | 3263 Property* property = expr->expression()->AsProperty(); |
3269 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 3264 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
3270 | 3265 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3717 Label* fall_through = NULL; | 3712 Label* fall_through = NULL; |
3718 context()->PrepareTest(&materialize_true, &materialize_false, | 3713 context()->PrepareTest(&materialize_true, &materialize_false, |
3719 &if_true, &if_false, &fall_through); | 3714 &if_true, &if_false, &fall_through); |
3720 | 3715 |
3721 Token::Value op = expr->op(); | 3716 Token::Value op = expr->op(); |
3722 VisitForStackValue(expr->left()); | 3717 VisitForStackValue(expr->left()); |
3723 switch (op) { | 3718 switch (op) { |
3724 case Token::IN: | 3719 case Token::IN: |
3725 VisitForStackValue(expr->right()); | 3720 VisitForStackValue(expr->right()); |
3726 SetExpressionPosition(expr); | 3721 SetExpressionPosition(expr); |
3727 CallRuntimeWithOperands(Runtime::kHasProperty); | 3722 EmitHasProperty(); |
3728 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); | 3723 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); |
3729 __ LoadRoot(t0, Heap::kTrueValueRootIndex); | 3724 __ LoadRoot(t0, Heap::kTrueValueRootIndex); |
3730 Split(eq, v0, Operand(t0), if_true, if_false, fall_through); | 3725 Split(eq, v0, Operand(t0), if_true, if_false, fall_through); |
3731 break; | 3726 break; |
3732 | 3727 |
3733 case Token::INSTANCEOF: { | 3728 case Token::INSTANCEOF: { |
3734 VisitForAccumulatorValue(expr->right()); | 3729 VisitForAccumulatorValue(expr->right()); |
3735 SetExpressionPosition(expr); | 3730 SetExpressionPosition(expr); |
3736 __ mov(a0, result_register()); | 3731 __ mov(a0, result_register()); |
3737 PopOperand(a1); | 3732 PopOperand(a1); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3984 reinterpret_cast<uint32_t>( | 3979 reinterpret_cast<uint32_t>( |
3985 isolate->builtins()->OnStackReplacement()->entry())); | 3980 isolate->builtins()->OnStackReplacement()->entry())); |
3986 return ON_STACK_REPLACEMENT; | 3981 return ON_STACK_REPLACEMENT; |
3987 } | 3982 } |
3988 | 3983 |
3989 | 3984 |
3990 } // namespace internal | 3985 } // namespace internal |
3991 } // namespace v8 | 3986 } // namespace v8 |
3992 | 3987 |
3993 #endif // V8_TARGET_ARCH_MIPS | 3988 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |