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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 151142: X64: Implement InstanceofStub. Prohibit zero-size code objects. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 5753 matching lines...) Expand 10 before | Expand all | Expand 10 after
5764 CallFunctionStub call_function(arg_count, in_loop); 5764 CallFunctionStub call_function(arg_count, in_loop);
5765 Result answer = frame_->CallStub(&call_function, arg_count + 1); 5765 Result answer = frame_->CallStub(&call_function, arg_count + 1);
5766 // Restore context and replace function on the stack with the 5766 // Restore context and replace function on the stack with the
5767 // result of the stub invocation. 5767 // result of the stub invocation.
5768 frame_->RestoreContextRegister(); 5768 frame_->RestoreContextRegister();
5769 frame_->SetElementAt(0, &answer); 5769 frame_->SetElementAt(0, &answer);
5770 } 5770 }
5771 5771
5772 5772
5773 void InstanceofStub::Generate(MacroAssembler* masm) { 5773 void InstanceofStub::Generate(MacroAssembler* masm) {
5774 // Implements "value instanceof function" operator.
5775 // Expected input state:
5776 // rsp[0] : return address
5777 // rsp[1] : function pointer
5778 // rsp[2] : value
5779
5780 // Get the object - go slow case if it's a smi.
5781 Label slow;
5782 __ movq(rax, Operand(rsp, 2 * kPointerSize));
5783 __ testl(rax, Immediate(kSmiTagMask));
5784 __ j(zero, &slow);
5785
5786 // Check that the left hand is a JS object. Leave its map in rax.
5787 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rax);
5788 __ j(below, &slow);
5789 __ CmpInstanceType(rax, LAST_JS_OBJECT_TYPE);
5790 __ j(above, &slow);
5791
5792 // Get the prototype of the function.
5793 __ movq(rdx, Operand(rsp, 1 * kPointerSize));
5794 __ TryGetFunctionPrototype(rdx, rbx, &slow);
5795
5796 // Check that the function prototype is a JS object.
5797 __ testl(rbx, Immediate(kSmiTagMask));
5798 __ j(zero, &slow);
5799 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, kScratchRegister);
5800 __ j(below, &slow);
5801 __ CmpInstanceType(kScratchRegister, LAST_JS_OBJECT_TYPE);
5802 __ j(above, &slow);
5803
5804 // Register mapping: rax is object map and rbx is function prototype.
5805 __ movq(rcx, FieldOperand(rax, Map::kPrototypeOffset));
5806
5807 // Loop through the prototype chain looking for the function prototype.
5808 Label loop, is_instance, is_not_instance;
5809 __ Move(kScratchRegister, Factory::null_value());
5810 __ bind(&loop);
5811 __ cmpq(rcx, rbx);
5812 __ j(equal, &is_instance);
5813 __ cmpq(rcx, kScratchRegister);
5814 __ j(equal, &is_not_instance);
5815 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset));
5816 __ movq(rcx, FieldOperand(rcx, Map::kPrototypeOffset));
5817 __ jmp(&loop);
5818
5819 __ bind(&is_instance);
5820 __ xor_(rax, rax);
5821 __ ret(2 * kPointerSize);
5822
5823 __ bind(&is_not_instance);
5824 __ movq(rax, Immediate(Smi::FromInt(1)));
5825 __ ret(2 * kPointerSize);
5826
5827 // Slow-case: Go through the JavaScript implementation.
5828 __ bind(&slow);
5829 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
5774 } 5830 }
5775 5831
5776 5832
5777 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { 5833 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
5778 // The displacement is used for skipping the return address and the 5834 // The displacement is used for skipping the return address and the
5779 // frame pointer on the stack. It is the offset of the last 5835 // frame pointer on the stack. It is the offset of the last
5780 // parameter (if any) relative to the frame pointer. 5836 // parameter (if any) relative to the frame pointer.
5781 static const int kDisplacement = 2 * kPointerSize; 5837 static const int kDisplacement = 2 * kPointerSize;
5782 5838
5783 // Check if the calling frame is an arguments adaptor frame. 5839 // Check if the calling frame is an arguments adaptor frame.
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
6838 int CompareStub::MinorKey() { 6894 int CompareStub::MinorKey() {
6839 // Encode the two parameters in a unique 16 bit value. 6895 // Encode the two parameters in a unique 16 bit value.
6840 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 6896 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
6841 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 6897 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
6842 } 6898 }
6843 6899
6844 6900
6845 #undef __ 6901 #undef __
6846 6902
6847 } } // namespace v8::internal 6903 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698