| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 default: return "GenericBinaryOpStub"; | 701 default: return "GenericBinaryOpStub"; |
| 702 } | 702 } |
| 703 } | 703 } |
| 704 | 704 |
| 705 #ifdef DEBUG | 705 #ifdef DEBUG |
| 706 void Print() { PrintF("GenericBinaryOpStub (%s)\n", Token::String(op_)); } | 706 void Print() { PrintF("GenericBinaryOpStub (%s)\n", Token::String(op_)); } |
| 707 #endif | 707 #endif |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 | 710 |
| 711 class InvokeBuiltinStub : public CodeStub { | |
| 712 public: | |
| 713 enum Kind { Inc, Dec, ToNumber }; | |
| 714 InvokeBuiltinStub(Kind kind, int argc) : kind_(kind), argc_(argc) { } | |
| 715 | |
| 716 private: | |
| 717 Kind kind_; | |
| 718 int argc_; | |
| 719 | |
| 720 Major MajorKey() { return InvokeBuiltin; } | |
| 721 int MinorKey() { return (argc_ << 3) | static_cast<int>(kind_); } | |
| 722 void Generate(MacroAssembler* masm); | |
| 723 | |
| 724 #ifdef DEBUG | |
| 725 void Print() { | |
| 726 PrintF("InvokeBuiltinStub (kind %d, argc, %d)\n", | |
| 727 static_cast<int>(kind_), | |
| 728 argc_); | |
| 729 } | |
| 730 #endif | |
| 731 }; | |
| 732 | |
| 733 | |
| 734 void CodeGenerator::GenericBinaryOperation(Token::Value op) { | 711 void CodeGenerator::GenericBinaryOperation(Token::Value op) { |
| 735 VirtualFrame::SpilledScope spilled_scope(this); | 712 VirtualFrame::SpilledScope spilled_scope(this); |
| 736 // sp[0] : y | 713 // sp[0] : y |
| 737 // sp[1] : x | 714 // sp[1] : x |
| 738 // result : r0 | 715 // result : r0 |
| 739 | 716 |
| 740 // Stub is entered with a call: 'return address' is in lr. | 717 // Stub is entered with a call: 'return address' is in lr. |
| 741 switch (op) { | 718 switch (op) { |
| 742 case Token::ADD: // fall through. | 719 case Token::ADD: // fall through. |
| 743 case Token::SUB: // fall through. | 720 case Token::SUB: // fall through. |
| (...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3689 | 3666 |
| 3690 // Revert optimistic increment/decrement. | 3667 // Revert optimistic increment/decrement. |
| 3691 if (is_increment) { | 3668 if (is_increment) { |
| 3692 __ sub(r0, r0, Operand(r1)); | 3669 __ sub(r0, r0, Operand(r1)); |
| 3693 } else { | 3670 } else { |
| 3694 __ add(r0, r0, Operand(r1)); | 3671 __ add(r0, r0, Operand(r1)); |
| 3695 } | 3672 } |
| 3696 | 3673 |
| 3697 // Slow case: Convert to number. | 3674 // Slow case: Convert to number. |
| 3698 slow.Bind(); | 3675 slow.Bind(); |
| 3699 | 3676 { |
| 3700 // Postfix: Convert the operand to a number and store it as the result. | 3677 // Convert the operand to a number. |
| 3678 frame_->EmitPush(r0); |
| 3679 Result arg_count = allocator_->Allocate(r0); |
| 3680 ASSERT(arg_count.is_valid()); |
| 3681 __ mov(arg_count.reg(), Operand(0)); |
| 3682 frame_->InvokeBuiltin(Builtins::TO_NUMBER, CALL_JS, &arg_count, 1); |
| 3683 } |
| 3701 if (is_postfix) { | 3684 if (is_postfix) { |
| 3702 InvokeBuiltinStub stub(InvokeBuiltinStub::ToNumber, 2); | 3685 // Postfix: store to result (on the stack). |
| 3703 frame_->CallStub(&stub, 0); | |
| 3704 // Store to result (on the stack). | |
| 3705 __ str(r0, frame_->ElementAt(target.size())); | 3686 __ str(r0, frame_->ElementAt(target.size())); |
| 3706 } | 3687 } |
| 3707 | 3688 |
| 3708 // Compute the new value by calling the right JavaScript native. | 3689 // Compute the new value. |
| 3690 __ mov(r1, Operand(Smi::FromInt(1))); |
| 3691 frame_->EmitPush(r0); |
| 3692 frame_->EmitPush(r1); |
| 3709 if (is_increment) { | 3693 if (is_increment) { |
| 3710 InvokeBuiltinStub stub(InvokeBuiltinStub::Inc, 1); | 3694 frame_->CallRuntime(Runtime::kNumberAdd, 2); |
| 3711 frame_->CallStub(&stub, 0); | |
| 3712 } else { | 3695 } else { |
| 3713 InvokeBuiltinStub stub(InvokeBuiltinStub::Dec, 1); | 3696 frame_->CallRuntime(Runtime::kNumberSub, 2); |
| 3714 frame_->CallStub(&stub, 0); | |
| 3715 } | 3697 } |
| 3716 | 3698 |
| 3717 // Store the new value in the target if not const. | 3699 // Store the new value in the target if not const. |
| 3718 exit.Bind(); | 3700 exit.Bind(); |
| 3719 frame_->EmitPush(r0); | 3701 frame_->EmitPush(r0); |
| 3720 if (!is_const) target.SetValue(NOT_CONST_INIT); | 3702 if (!is_const) target.SetValue(NOT_CONST_INIT); |
| 3721 } | 3703 } |
| 3722 | 3704 |
| 3723 // Postfix: Discard the new value and use the old. | 3705 // Postfix: Discard the new value and use the old. |
| 3724 if (is_postfix) frame_->EmitPop(r0); | 3706 if (is_postfix) frame_->EmitPop(r0); |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4711 __ bind(&slow); | 4693 __ bind(&slow); |
| 4712 __ push(r0); | 4694 __ push(r0); |
| 4713 __ mov(r0, Operand(0)); // set number of arguments | 4695 __ mov(r0, Operand(0)); // set number of arguments |
| 4714 __ InvokeBuiltin(Builtins::UNARY_MINUS, JUMP_JS); | 4696 __ InvokeBuiltin(Builtins::UNARY_MINUS, JUMP_JS); |
| 4715 | 4697 |
| 4716 __ bind(&done); | 4698 __ bind(&done); |
| 4717 __ StubReturn(1); | 4699 __ StubReturn(1); |
| 4718 } | 4700 } |
| 4719 | 4701 |
| 4720 | 4702 |
| 4721 void InvokeBuiltinStub::Generate(MacroAssembler* masm) { | |
| 4722 __ push(r0); | |
| 4723 __ mov(r0, Operand(0)); // set number of arguments | |
| 4724 switch (kind_) { | |
| 4725 case ToNumber: __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_JS); break; | |
| 4726 case Inc: __ InvokeBuiltin(Builtins::INC, JUMP_JS); break; | |
| 4727 case Dec: __ InvokeBuiltin(Builtins::DEC, JUMP_JS); break; | |
| 4728 default: UNREACHABLE(); | |
| 4729 } | |
| 4730 __ StubReturn(argc_); | |
| 4731 } | |
| 4732 | |
| 4733 | |
| 4734 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { | 4703 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { |
| 4735 // r0 holds exception | 4704 // r0 holds exception |
| 4736 ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code | 4705 ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code |
| 4737 __ mov(r3, Operand(ExternalReference(Top::k_handler_address))); | 4706 __ mov(r3, Operand(ExternalReference(Top::k_handler_address))); |
| 4738 __ ldr(sp, MemOperand(r3)); | 4707 __ ldr(sp, MemOperand(r3)); |
| 4739 __ pop(r2); // pop next in chain | 4708 __ pop(r2); // pop next in chain |
| 4740 __ str(r2, MemOperand(r3)); | 4709 __ str(r2, MemOperand(r3)); |
| 4741 // restore parameter- and frame-pointer and pop state. | 4710 // restore parameter- and frame-pointer and pop state. |
| 4742 __ ldm(ia_w, sp, r3.bit() | pp.bit() | fp.bit()); | 4711 __ ldm(ia_w, sp, r3.bit() | pp.bit() | fp.bit()); |
| 4743 // Before returning we restore the context from the frame pointer if not NULL. | 4712 // Before returning we restore the context from the frame pointer if not NULL. |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5220 __ mov(r2, Operand(0)); | 5189 __ mov(r2, Operand(0)); |
| 5221 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 5190 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 5222 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 5191 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
| 5223 RelocInfo::CODE_TARGET); | 5192 RelocInfo::CODE_TARGET); |
| 5224 } | 5193 } |
| 5225 | 5194 |
| 5226 | 5195 |
| 5227 #undef __ | 5196 #undef __ |
| 5228 | 5197 |
| 5229 } } // namespace v8::internal | 5198 } } // namespace v8::internal |
| OLD | NEW |