| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_IA32) |
| 31 |
| 30 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 31 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
| 32 #include "compiler.h" | 34 #include "compiler.h" |
| 33 #include "debug.h" | 35 #include "debug.h" |
| 34 #include "ic-inl.h" | 36 #include "ic-inl.h" |
| 35 #include "jsregexp.h" | 37 #include "jsregexp.h" |
| 36 #include "parser.h" | 38 #include "parser.h" |
| 37 #include "regexp-macro-assembler.h" | 39 #include "regexp-macro-assembler.h" |
| 38 #include "regexp-stack.h" | 40 #include "regexp-stack.h" |
| 39 #include "register-allocator-inl.h" | 41 #include "register-allocator-inl.h" |
| (...skipping 2932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2972 | 2974 |
| 2973 // Call the function just below TOS on the stack with the given | 2975 // Call the function just below TOS on the stack with the given |
| 2974 // arguments. The receiver is the TOS. | 2976 // arguments. The receiver is the TOS. |
| 2975 void CodeGenerator::CallWithArguments(ZoneList<Expression*>* args, | 2977 void CodeGenerator::CallWithArguments(ZoneList<Expression*>* args, |
| 2976 CallFunctionFlags flags, | 2978 CallFunctionFlags flags, |
| 2977 int position) { | 2979 int position) { |
| 2978 // Push the arguments ("left-to-right") on the stack. | 2980 // Push the arguments ("left-to-right") on the stack. |
| 2979 int arg_count = args->length(); | 2981 int arg_count = args->length(); |
| 2980 for (int i = 0; i < arg_count; i++) { | 2982 for (int i = 0; i < arg_count; i++) { |
| 2981 Load(args->at(i)); | 2983 Load(args->at(i)); |
| 2984 frame_->SpillTop(); |
| 2982 } | 2985 } |
| 2983 | 2986 |
| 2984 // Record the position for debugging purposes. | 2987 // Record the position for debugging purposes. |
| 2985 CodeForSourcePosition(position); | 2988 CodeForSourcePosition(position); |
| 2986 | 2989 |
| 2987 // Use the shared code stub to call the function. | 2990 // Use the shared code stub to call the function. |
| 2988 InLoopFlag in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; | 2991 InLoopFlag in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 2989 CallFunctionStub call_function(arg_count, in_loop, flags); | 2992 CallFunctionStub call_function(arg_count, in_loop, flags); |
| 2990 Result answer = frame_->CallStub(&call_function, arg_count + 1); | 2993 Result answer = frame_->CallStub(&call_function, arg_count + 1); |
| 2991 // Restore context and replace function on the stack with the | 2994 // Restore context and replace function on the stack with the |
| (...skipping 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5723 // arguments. | 5726 // arguments. |
| 5724 | 5727 |
| 5725 // Prepare the stack for the call to the resolved function. | 5728 // Prepare the stack for the call to the resolved function. |
| 5726 Load(function); | 5729 Load(function); |
| 5727 | 5730 |
| 5728 // Allocate a frame slot for the receiver. | 5731 // Allocate a frame slot for the receiver. |
| 5729 frame_->Push(Factory::undefined_value()); | 5732 frame_->Push(Factory::undefined_value()); |
| 5730 int arg_count = args->length(); | 5733 int arg_count = args->length(); |
| 5731 for (int i = 0; i < arg_count; i++) { | 5734 for (int i = 0; i < arg_count; i++) { |
| 5732 Load(args->at(i)); | 5735 Load(args->at(i)); |
| 5736 frame_->SpillTop(); |
| 5733 } | 5737 } |
| 5734 | 5738 |
| 5735 // Prepare the stack for the call to ResolvePossiblyDirectEval. | 5739 // Prepare the stack for the call to ResolvePossiblyDirectEval. |
| 5736 frame_->PushElementAt(arg_count + 1); | 5740 frame_->PushElementAt(arg_count + 1); |
| 5737 if (arg_count > 0) { | 5741 if (arg_count > 0) { |
| 5738 frame_->PushElementAt(arg_count); | 5742 frame_->PushElementAt(arg_count); |
| 5739 } else { | 5743 } else { |
| 5740 frame_->Push(Factory::undefined_value()); | 5744 frame_->Push(Factory::undefined_value()); |
| 5741 } | 5745 } |
| 5742 | 5746 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5772 | 5776 |
| 5773 // Pass the global object as the receiver and let the IC stub | 5777 // Pass the global object as the receiver and let the IC stub |
| 5774 // patch the stack to use the global proxy as 'this' in the | 5778 // patch the stack to use the global proxy as 'this' in the |
| 5775 // invoked function. | 5779 // invoked function. |
| 5776 LoadGlobal(); | 5780 LoadGlobal(); |
| 5777 | 5781 |
| 5778 // Load the arguments. | 5782 // Load the arguments. |
| 5779 int arg_count = args->length(); | 5783 int arg_count = args->length(); |
| 5780 for (int i = 0; i < arg_count; i++) { | 5784 for (int i = 0; i < arg_count; i++) { |
| 5781 Load(args->at(i)); | 5785 Load(args->at(i)); |
| 5786 frame_->SpillTop(); |
| 5782 } | 5787 } |
| 5783 | 5788 |
| 5784 // Push the name of the function onto the frame. | 5789 // Push the name of the function onto the frame. |
| 5785 frame_->Push(var->name()); | 5790 frame_->Push(var->name()); |
| 5786 | 5791 |
| 5787 // Call the IC initialization code. | 5792 // Call the IC initialization code. |
| 5788 CodeForSourcePosition(node->position()); | 5793 CodeForSourcePosition(node->position()); |
| 5789 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, | 5794 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, |
| 5790 arg_count, | 5795 arg_count, |
| 5791 loop_nesting()); | 5796 loop_nesting()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5877 node->position()); | 5882 node->position()); |
| 5878 | 5883 |
| 5879 } else { | 5884 } else { |
| 5880 // Push the receiver onto the frame. | 5885 // Push the receiver onto the frame. |
| 5881 Load(property->obj()); | 5886 Load(property->obj()); |
| 5882 | 5887 |
| 5883 // Load the arguments. | 5888 // Load the arguments. |
| 5884 int arg_count = args->length(); | 5889 int arg_count = args->length(); |
| 5885 for (int i = 0; i < arg_count; i++) { | 5890 for (int i = 0; i < arg_count; i++) { |
| 5886 Load(args->at(i)); | 5891 Load(args->at(i)); |
| 5892 frame_->SpillTop(); |
| 5887 } | 5893 } |
| 5888 | 5894 |
| 5889 // Push the name of the function onto the frame. | 5895 // Push the name of the function onto the frame. |
| 5890 frame_->Push(name); | 5896 frame_->Push(name); |
| 5891 | 5897 |
| 5892 // Call the IC initialization code. | 5898 // Call the IC initialization code. |
| 5893 CodeForSourcePosition(node->position()); | 5899 CodeForSourcePosition(node->position()); |
| 5894 Result result = | 5900 Result result = |
| 5895 frame_->CallCallIC(RelocInfo::CODE_TARGET, arg_count, | 5901 frame_->CallCallIC(RelocInfo::CODE_TARGET, arg_count, |
| 5896 loop_nesting()); | 5902 loop_nesting()); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6152 Result map = allocator()->Allocate(); | 6158 Result map = allocator()->Allocate(); |
| 6153 ASSERT(map.is_valid()); | 6159 ASSERT(map.is_valid()); |
| 6154 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); | 6160 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 6155 // Undetectable objects behave like undefined when tested with typeof. | 6161 // Undetectable objects behave like undefined when tested with typeof. |
| 6156 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kBitFieldOffset)); | 6162 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kBitFieldOffset)); |
| 6157 __ test(map.reg(), Immediate(1 << Map::kIsUndetectable)); | 6163 __ test(map.reg(), Immediate(1 << Map::kIsUndetectable)); |
| 6158 destination()->false_target()->Branch(not_zero); | 6164 destination()->false_target()->Branch(not_zero); |
| 6159 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); | 6165 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 6160 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kInstanceTypeOffset)); | 6166 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kInstanceTypeOffset)); |
| 6161 __ cmp(map.reg(), FIRST_JS_OBJECT_TYPE); | 6167 __ cmp(map.reg(), FIRST_JS_OBJECT_TYPE); |
| 6162 destination()->false_target()->Branch(less); | 6168 destination()->false_target()->Branch(below); |
| 6163 __ cmp(map.reg(), LAST_JS_OBJECT_TYPE); | 6169 __ cmp(map.reg(), LAST_JS_OBJECT_TYPE); |
| 6164 obj.Unuse(); | 6170 obj.Unuse(); |
| 6165 map.Unuse(); | 6171 map.Unuse(); |
| 6166 destination()->Split(less_equal); | 6172 destination()->Split(below_equal); |
| 6167 } | 6173 } |
| 6168 | 6174 |
| 6169 | 6175 |
| 6170 void CodeGenerator::GenerateIsFunction(ZoneList<Expression*>* args) { | 6176 void CodeGenerator::GenerateIsFunction(ZoneList<Expression*>* args) { |
| 6171 // This generates a fast version of: | 6177 // This generates a fast version of: |
| 6172 // (%_ClassOf(arg) === 'Function') | 6178 // (%_ClassOf(arg) === 'Function') |
| 6173 ASSERT(args->length() == 1); | 6179 ASSERT(args->length() == 1); |
| 6174 Load(args->at(0)); | 6180 Load(args->at(0)); |
| 6175 Result obj = frame_->Pop(); | 6181 Result obj = frame_->Pop(); |
| 6176 obj.ToRegister(); | 6182 obj.ToRegister(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6269 // If the object is a smi, we return null. | 6275 // If the object is a smi, we return null. |
| 6270 __ test(obj.reg(), Immediate(kSmiTagMask)); | 6276 __ test(obj.reg(), Immediate(kSmiTagMask)); |
| 6271 null.Branch(zero); | 6277 null.Branch(zero); |
| 6272 | 6278 |
| 6273 // Check that the object is a JS object but take special care of JS | 6279 // Check that the object is a JS object but take special care of JS |
| 6274 // functions to make sure they have 'Function' as their class. | 6280 // functions to make sure they have 'Function' as their class. |
| 6275 { Result tmp = allocator()->Allocate(); | 6281 { Result tmp = allocator()->Allocate(); |
| 6276 __ mov(obj.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); | 6282 __ mov(obj.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 6277 __ movzx_b(tmp.reg(), FieldOperand(obj.reg(), Map::kInstanceTypeOffset)); | 6283 __ movzx_b(tmp.reg(), FieldOperand(obj.reg(), Map::kInstanceTypeOffset)); |
| 6278 __ cmp(tmp.reg(), FIRST_JS_OBJECT_TYPE); | 6284 __ cmp(tmp.reg(), FIRST_JS_OBJECT_TYPE); |
| 6279 null.Branch(less); | 6285 null.Branch(below); |
| 6280 | 6286 |
| 6281 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 6287 // As long as JS_FUNCTION_TYPE is the last instance type and it is |
| 6282 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 6288 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for |
| 6283 // LAST_JS_OBJECT_TYPE. | 6289 // LAST_JS_OBJECT_TYPE. |
| 6284 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 6290 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 6285 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 6291 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); |
| 6286 __ cmp(tmp.reg(), JS_FUNCTION_TYPE); | 6292 __ cmp(tmp.reg(), JS_FUNCTION_TYPE); |
| 6287 function.Branch(equal); | 6293 function.Branch(equal); |
| 6288 } | 6294 } |
| 6289 | 6295 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6859 frame_->Spill(index2.reg()); | 6865 frame_->Spill(index2.reg()); |
| 6860 | 6866 |
| 6861 DeferredSwapElements* deferred = new DeferredSwapElements(object.reg(), | 6867 DeferredSwapElements* deferred = new DeferredSwapElements(object.reg(), |
| 6862 index1.reg(), | 6868 index1.reg(), |
| 6863 index2.reg()); | 6869 index2.reg()); |
| 6864 | 6870 |
| 6865 // Fetch the map and check if array is in fast case. | 6871 // Fetch the map and check if array is in fast case. |
| 6866 // Check that object doesn't require security checks and | 6872 // Check that object doesn't require security checks and |
| 6867 // has no indexed interceptor. | 6873 // has no indexed interceptor. |
| 6868 __ CmpObjectType(object.reg(), FIRST_JS_OBJECT_TYPE, tmp1.reg()); | 6874 __ CmpObjectType(object.reg(), FIRST_JS_OBJECT_TYPE, tmp1.reg()); |
| 6869 deferred->Branch(less); | 6875 deferred->Branch(below); |
| 6870 __ movzx_b(tmp1.reg(), FieldOperand(tmp1.reg(), Map::kBitFieldOffset)); | 6876 __ movzx_b(tmp1.reg(), FieldOperand(tmp1.reg(), Map::kBitFieldOffset)); |
| 6871 __ test(tmp1.reg(), Immediate(KeyedLoadIC::kSlowCaseBitFieldMask)); | 6877 __ test(tmp1.reg(), Immediate(KeyedLoadIC::kSlowCaseBitFieldMask)); |
| 6872 deferred->Branch(not_zero); | 6878 deferred->Branch(not_zero); |
| 6873 | 6879 |
| 6874 // Check the object's elements are in fast case. | 6880 // Check the object's elements are in fast case. |
| 6875 __ mov(tmp1.reg(), FieldOperand(object.reg(), JSObject::kElementsOffset)); | 6881 __ mov(tmp1.reg(), FieldOperand(object.reg(), JSObject::kElementsOffset)); |
| 6876 __ cmp(FieldOperand(tmp1.reg(), HeapObject::kMapOffset), | 6882 __ cmp(FieldOperand(tmp1.reg(), HeapObject::kMapOffset), |
| 6877 Immediate(Factory::fixed_array_map())); | 6883 Immediate(Factory::fixed_array_map())); |
| 6878 deferred->Branch(not_equal); | 6884 deferred->Branch(not_equal); |
| 6879 | 6885 |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8179 __ CmpObjectType(answer.reg(), JS_REGEXP_TYPE, map.reg()); | 8185 __ CmpObjectType(answer.reg(), JS_REGEXP_TYPE, map.reg()); |
| 8180 destination()->false_target()->Branch(equal); | 8186 destination()->false_target()->Branch(equal); |
| 8181 | 8187 |
| 8182 // It can be an undetectable object. | 8188 // It can be an undetectable object. |
| 8183 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kBitFieldOffset)); | 8189 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kBitFieldOffset)); |
| 8184 __ test(map.reg(), Immediate(1 << Map::kIsUndetectable)); | 8190 __ test(map.reg(), Immediate(1 << Map::kIsUndetectable)); |
| 8185 destination()->false_target()->Branch(not_zero); | 8191 destination()->false_target()->Branch(not_zero); |
| 8186 __ mov(map.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset)); | 8192 __ mov(map.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset)); |
| 8187 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kInstanceTypeOffset)); | 8193 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kInstanceTypeOffset)); |
| 8188 __ cmp(map.reg(), FIRST_JS_OBJECT_TYPE); | 8194 __ cmp(map.reg(), FIRST_JS_OBJECT_TYPE); |
| 8189 destination()->false_target()->Branch(less); | 8195 destination()->false_target()->Branch(below); |
| 8190 __ cmp(map.reg(), LAST_JS_OBJECT_TYPE); | 8196 __ cmp(map.reg(), LAST_JS_OBJECT_TYPE); |
| 8191 answer.Unuse(); | 8197 answer.Unuse(); |
| 8192 map.Unuse(); | 8198 map.Unuse(); |
| 8193 destination()->Split(less_equal); | 8199 destination()->Split(below_equal); |
| 8194 } else { | 8200 } else { |
| 8195 // Uncommon case: typeof testing against a string literal that is | 8201 // Uncommon case: typeof testing against a string literal that is |
| 8196 // never returned from the typeof operator. | 8202 // never returned from the typeof operator. |
| 8197 answer.Unuse(); | 8203 answer.Unuse(); |
| 8198 destination()->Goto(false); | 8204 destination()->Goto(false); |
| 8199 } | 8205 } |
| 8200 return; | 8206 return; |
| 8201 } else if (op == Token::LT && | 8207 } else if (op == Token::LT && |
| 8202 right->AsLiteral() != NULL && | 8208 right->AsLiteral() != NULL && |
| 8203 right->AsLiteral()->handle()->IsHeapNumber()) { | 8209 right->AsLiteral()->handle()->IsHeapNumber()) { |
| (...skipping 3385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11589 // There is no test for undetectability in strict equality. | 11595 // There is no test for undetectability in strict equality. |
| 11590 | 11596 |
| 11591 // Get the type of the first operand. | 11597 // Get the type of the first operand. |
| 11592 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 11598 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 11593 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 11599 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
| 11594 | 11600 |
| 11595 // If the first object is a JS object, we have done pointer comparison. | 11601 // If the first object is a JS object, we have done pointer comparison. |
| 11596 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 11602 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 11597 Label first_non_object; | 11603 Label first_non_object; |
| 11598 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 11604 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
| 11599 __ j(less, &first_non_object); | 11605 __ j(below, &first_non_object); |
| 11600 | 11606 |
| 11601 // Return non-zero (eax is not zero) | 11607 // Return non-zero (eax is not zero) |
| 11602 Label return_not_equal; | 11608 Label return_not_equal; |
| 11603 ASSERT(kHeapObjectTag != 0); | 11609 ASSERT(kHeapObjectTag != 0); |
| 11604 __ bind(&return_not_equal); | 11610 __ bind(&return_not_equal); |
| 11605 __ ret(0); | 11611 __ ret(0); |
| 11606 | 11612 |
| 11607 __ bind(&first_non_object); | 11613 __ bind(&first_non_object); |
| 11608 // Check for oddballs: true, false, null, undefined. | 11614 // Check for oddballs: true, false, null, undefined. |
| 11609 __ cmp(ecx, ODDBALL_TYPE); | 11615 __ cmp(ecx, ODDBALL_TYPE); |
| 11610 __ j(equal, &return_not_equal); | 11616 __ j(equal, &return_not_equal); |
| 11611 | 11617 |
| 11612 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); | 11618 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 11613 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 11619 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
| 11614 | 11620 |
| 11615 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 11621 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
| 11616 __ j(greater_equal, &return_not_equal); | 11622 __ j(above_equal, &return_not_equal); |
| 11617 | 11623 |
| 11618 // Check for oddballs: true, false, null, undefined. | 11624 // Check for oddballs: true, false, null, undefined. |
| 11619 __ cmp(ecx, ODDBALL_TYPE); | 11625 __ cmp(ecx, ODDBALL_TYPE); |
| 11620 __ j(equal, &return_not_equal); | 11626 __ j(equal, &return_not_equal); |
| 11621 | 11627 |
| 11622 // Fall through to the general case. | 11628 // Fall through to the general case. |
| 11623 } | 11629 } |
| 11624 __ bind(&slow); | 11630 __ bind(&slow); |
| 11625 } | 11631 } |
| 11626 | 11632 |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12254 // Get the object - go slow case if it's a smi. | 12260 // Get the object - go slow case if it's a smi. |
| 12255 Label slow; | 12261 Label slow; |
| 12256 __ mov(eax, Operand(esp, 2 * kPointerSize)); // 2 ~ return address, function | 12262 __ mov(eax, Operand(esp, 2 * kPointerSize)); // 2 ~ return address, function |
| 12257 __ test(eax, Immediate(kSmiTagMask)); | 12263 __ test(eax, Immediate(kSmiTagMask)); |
| 12258 __ j(zero, &slow, not_taken); | 12264 __ j(zero, &slow, not_taken); |
| 12259 | 12265 |
| 12260 // Check that the left hand is a JS object. | 12266 // Check that the left hand is a JS object. |
| 12261 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); // eax - object map | 12267 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); // eax - object map |
| 12262 __ movzx_b(ecx, FieldOperand(eax, Map::kInstanceTypeOffset)); // ecx - type | 12268 __ movzx_b(ecx, FieldOperand(eax, Map::kInstanceTypeOffset)); // ecx - type |
| 12263 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 12269 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
| 12264 __ j(less, &slow, not_taken); | 12270 __ j(below, &slow, not_taken); |
| 12265 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 12271 __ cmp(ecx, LAST_JS_OBJECT_TYPE); |
| 12266 __ j(greater, &slow, not_taken); | 12272 __ j(above, &slow, not_taken); |
| 12267 | 12273 |
| 12268 // Get the prototype of the function. | 12274 // Get the prototype of the function. |
| 12269 __ mov(edx, Operand(esp, 1 * kPointerSize)); // 1 ~ return address | 12275 __ mov(edx, Operand(esp, 1 * kPointerSize)); // 1 ~ return address |
| 12270 // edx is function, eax is map. | 12276 // edx is function, eax is map. |
| 12271 | 12277 |
| 12272 // Look up the function and the map in the instanceof cache. | 12278 // Look up the function and the map in the instanceof cache. |
| 12273 Label miss; | 12279 Label miss; |
| 12274 ExternalReference roots_address = ExternalReference::roots_address(); | 12280 ExternalReference roots_address = ExternalReference::roots_address(); |
| 12275 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); | 12281 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); |
| 12276 __ cmp(edx, Operand::StaticArray(ecx, times_pointer_size, roots_address)); | 12282 __ cmp(edx, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12277 __ j(not_equal, &miss); | 12283 __ j(not_equal, &miss); |
| 12278 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); | 12284 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); |
| 12279 __ cmp(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); | 12285 __ cmp(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12280 __ j(not_equal, &miss); | 12286 __ j(not_equal, &miss); |
| 12281 __ mov(ecx, Immediate(Heap::kInstanceofCacheAnswerRootIndex)); | 12287 __ mov(ecx, Immediate(Heap::kInstanceofCacheAnswerRootIndex)); |
| 12282 __ mov(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); | 12288 __ mov(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12283 __ ret(2 * kPointerSize); | 12289 __ ret(2 * kPointerSize); |
| 12284 | 12290 |
| 12285 __ bind(&miss); | 12291 __ bind(&miss); |
| 12286 __ TryGetFunctionPrototype(edx, ebx, ecx, &slow); | 12292 __ TryGetFunctionPrototype(edx, ebx, ecx, &slow); |
| 12287 | 12293 |
| 12288 // Check that the function prototype is a JS object. | 12294 // Check that the function prototype is a JS object. |
| 12289 __ test(ebx, Immediate(kSmiTagMask)); | 12295 __ test(ebx, Immediate(kSmiTagMask)); |
| 12290 __ j(zero, &slow, not_taken); | 12296 __ j(zero, &slow, not_taken); |
| 12291 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); | 12297 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 12292 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 12298 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
| 12293 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 12299 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
| 12294 __ j(less, &slow, not_taken); | 12300 __ j(below, &slow, not_taken); |
| 12295 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 12301 __ cmp(ecx, LAST_JS_OBJECT_TYPE); |
| 12296 __ j(greater, &slow, not_taken); | 12302 __ j(above, &slow, not_taken); |
| 12297 | 12303 |
| 12298 // Register mapping: | 12304 // Register mapping: |
| 12299 // eax is object map. | 12305 // eax is object map. |
| 12300 // edx is function. | 12306 // edx is function. |
| 12301 // ebx is function prototype. | 12307 // ebx is function prototype. |
| 12302 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); | 12308 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); |
| 12303 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), eax); | 12309 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), eax); |
| 12304 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); | 12310 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); |
| 12305 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), edx); | 12311 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), edx); |
| 12306 | 12312 |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13284 | 13290 |
| 13285 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 13291 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 13286 // tagged as a small integer. | 13292 // tagged as a small integer. |
| 13287 __ bind(&runtime); | 13293 __ bind(&runtime); |
| 13288 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 13294 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 13289 } | 13295 } |
| 13290 | 13296 |
| 13291 #undef __ | 13297 #undef __ |
| 13292 | 13298 |
| 13293 } } // namespace v8::internal | 13299 } } // namespace v8::internal |
| 13300 |
| 13301 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |