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 4852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4863 Result temp = allocator()->Allocate(); | 4863 Result temp = allocator()->Allocate(); |
4864 ASSERT(temp.is_valid()); | 4864 ASSERT(temp.is_valid()); |
4865 // Check if the object is a JS array or not. | 4865 // Check if the object is a JS array or not. |
4866 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, temp.reg()); | 4866 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, temp.reg()); |
4867 value.Unuse(); | 4867 value.Unuse(); |
4868 temp.Unuse(); | 4868 temp.Unuse(); |
4869 destination()->Split(equal); | 4869 destination()->Split(equal); |
4870 } | 4870 } |
4871 | 4871 |
4872 | 4872 |
| 4873 void CodeGenerator::GenerateIsObject(ZoneList<Expression*>* args) { |
| 4874 // This generates a fast version of: |
| 4875 // (typeof(arg) === 'object' || %_ClassOf(arg) == 'RegExp') |
| 4876 ASSERT(args->length() == 1); |
| 4877 Load(args->at(0)); |
| 4878 Result obj = frame_->Pop(); |
| 4879 obj.ToRegister(); |
| 4880 |
| 4881 __ test(obj.reg(), Immediate(kSmiTagMask)); |
| 4882 destination()->false_target()->Branch(zero); |
| 4883 __ cmp(obj.reg(), Factory::null_value()); |
| 4884 destination()->true_target()->Branch(equal); |
| 4885 |
| 4886 Result map = allocator()->Allocate(); |
| 4887 ASSERT(map.is_valid()); |
| 4888 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 4889 // Undetectable objects behave like undefined when tested with typeof. |
| 4890 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kBitFieldOffset)); |
| 4891 __ test(map.reg(), Immediate(1 << Map::kIsUndetectable)); |
| 4892 destination()->false_target()->Branch(not_zero); |
| 4893 __ mov(map.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 4894 __ movzx_b(map.reg(), FieldOperand(map.reg(), Map::kInstanceTypeOffset)); |
| 4895 __ cmp(map.reg(), FIRST_JS_OBJECT_TYPE); |
| 4896 destination()->false_target()->Branch(less); |
| 4897 __ cmp(map.reg(), LAST_JS_OBJECT_TYPE); |
| 4898 obj.Unuse(); |
| 4899 map.Unuse(); |
| 4900 destination()->Split(less_equal); |
| 4901 } |
| 4902 |
| 4903 |
| 4904 void CodeGenerator::GenerateIsFunction(ZoneList<Expression*>* args) { |
| 4905 // This generates a fast version of: |
| 4906 // (%_ClassOf(arg) === 'Function') |
| 4907 ASSERT(args->length() == 1); |
| 4908 Load(args->at(0)); |
| 4909 Result obj = frame_->Pop(); |
| 4910 obj.ToRegister(); |
| 4911 __ test(obj.reg(), Immediate(kSmiTagMask)); |
| 4912 destination()->false_target()->Branch(zero); |
| 4913 Result temp = allocator()->Allocate(); |
| 4914 ASSERT(temp.is_valid()); |
| 4915 __ CmpObjectType(obj.reg(), JS_FUNCTION_TYPE, temp.reg()); |
| 4916 obj.Unuse(); |
| 4917 temp.Unuse(); |
| 4918 destination()->Split(equal); |
| 4919 } |
| 4920 |
| 4921 |
4873 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) { | 4922 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) { |
4874 ASSERT(args->length() == 0); | 4923 ASSERT(args->length() == 0); |
4875 | 4924 |
4876 // Get the frame pointer for the calling frame. | 4925 // Get the frame pointer for the calling frame. |
4877 Result fp = allocator()->Allocate(); | 4926 Result fp = allocator()->Allocate(); |
4878 __ mov(fp.reg(), Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 4927 __ mov(fp.reg(), Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
4879 | 4928 |
4880 // Skip the arguments adaptor frame if it exists. | 4929 // Skip the arguments adaptor frame if it exists. |
4881 Label check_frame_marker; | 4930 Label check_frame_marker; |
4882 __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset), | 4931 __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset), |
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8132 | 8181 |
8133 int CompareStub::MinorKey() { | 8182 int CompareStub::MinorKey() { |
8134 // Encode the two parameters in a unique 16 bit value. | 8183 // Encode the two parameters in a unique 16 bit value. |
8135 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 8184 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
8136 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 8185 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
8137 } | 8186 } |
8138 | 8187 |
8139 #undef __ | 8188 #undef __ |
8140 | 8189 |
8141 } } // namespace v8::internal | 8190 } } // namespace v8::internal |
OLD | NEW |