OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 // the temp registers, but not the input. Only input and temp2 may alias. | 1910 // the temp registers, but not the input. Only input and temp2 may alias. |
1911 void LCodeGen::EmitClassOfTest(Label* is_true, | 1911 void LCodeGen::EmitClassOfTest(Label* is_true, |
1912 Label* is_false, | 1912 Label* is_false, |
1913 Handle<String>class_name, | 1913 Handle<String>class_name, |
1914 Register input, | 1914 Register input, |
1915 Register temp, | 1915 Register temp, |
1916 Register temp2) { | 1916 Register temp2) { |
1917 ASSERT(!input.is(temp)); | 1917 ASSERT(!input.is(temp)); |
1918 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. | 1918 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
1919 __ JumpIfSmi(input, is_false); | 1919 __ JumpIfSmi(input, is_false); |
| 1920 |
| 1921 // Assuming the following assertions, we can do the same test for |
| 1922 // either "Object" or "Function", only the branch conditions differ. |
| 1923 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 1924 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1925 FIRST_SPEC_OBJECT_TYPE + 1); |
| 1926 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1927 LAST_SPEC_OBJECT_TYPE - 1); |
| 1928 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 1929 |
| 1930 // Functions have class 'Function'. |
1920 __ CompareObjectType(input, temp, temp2, FIRST_SPEC_OBJECT_TYPE); | 1931 __ CompareObjectType(input, temp, temp2, FIRST_SPEC_OBJECT_TYPE); |
1921 __ b(lt, is_false); | 1932 // Map is now in temp, type in temp2. |
1922 | |
1923 // Map is now in temp. | |
1924 // Functions have class 'Function'. | |
1925 __ CompareInstanceType(temp, temp2, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
1926 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1933 if (class_name->IsEqualTo(CStrVector("Function"))) { |
1927 __ b(ge, is_true); | 1934 __ b(lt, is_false); |
| 1935 __ b(eq, is_true); |
| 1936 } else { |
| 1937 __ b(le, is_false); |
| 1938 } |
| 1939 __ cmp(temp2, Operand(LAST_SPEC_OBJECT_TYPE)); |
| 1940 if (class_name->IsEqualTo(CStrVector("Function"))) { |
| 1941 __ b(eq, is_true); |
1928 } else { | 1942 } else { |
1929 __ b(ge, is_false); | 1943 __ b(ge, is_false); |
1930 } | 1944 } |
1931 | 1945 |
| 1946 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
1932 // Check if the constructor in the map is a function. | 1947 // Check if the constructor in the map is a function. |
1933 __ ldr(temp, FieldMemOperand(temp, Map::kConstructorOffset)); | 1948 __ ldr(temp, FieldMemOperand(temp, Map::kConstructorOffset)); |
1934 | 1949 |
1935 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type and | |
1936 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | |
1937 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | |
1938 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | |
1939 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | |
1940 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | |
1941 | |
1942 // Objects with a non-function constructor have class 'Object'. | 1950 // Objects with a non-function constructor have class 'Object'. |
1943 __ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE); | 1951 __ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE); |
1944 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1952 if (class_name->IsEqualTo(CStrVector("Object"))) { |
1945 __ b(ne, is_true); | 1953 __ b(ne, is_true); |
1946 } else { | 1954 } else { |
1947 __ b(ne, is_false); | 1955 __ b(ne, is_false); |
1948 } | 1956 } |
1949 | 1957 |
1950 // temp now contains the constructor function. Grab the | 1958 // temp now contains the constructor function. Grab the |
1951 // instance class name from there. | 1959 // instance class name from there. |
(...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4335 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); | 4343 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); |
4336 __ b(eq, true_label); | 4344 __ b(eq, true_label); |
4337 __ JumpIfSmi(input, false_label); | 4345 __ JumpIfSmi(input, false_label); |
4338 // Check for undetectable objects => true. | 4346 // Check for undetectable objects => true. |
4339 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); | 4347 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); |
4340 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset)); | 4348 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset)); |
4341 __ tst(ip, Operand(1 << Map::kIsUndetectable)); | 4349 __ tst(ip, Operand(1 << Map::kIsUndetectable)); |
4342 final_branch_condition = ne; | 4350 final_branch_condition = ne; |
4343 | 4351 |
4344 } else if (type_name->Equals(heap()->function_symbol())) { | 4352 } else if (type_name->Equals(heap()->function_symbol())) { |
| 4353 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
4345 __ JumpIfSmi(input, false_label); | 4354 __ JumpIfSmi(input, false_label); |
4346 __ CompareObjectType(input, input, scratch, | 4355 __ CompareObjectType(input, scratch, input, JS_FUNCTION_TYPE); |
4347 FIRST_CALLABLE_SPEC_OBJECT_TYPE); | 4356 __ b(eq, true_label); |
4348 final_branch_condition = ge; | 4357 __ cmp(input, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 4358 final_branch_condition = eq; |
4349 | 4359 |
4350 } else if (type_name->Equals(heap()->object_symbol())) { | 4360 } else if (type_name->Equals(heap()->object_symbol())) { |
4351 __ JumpIfSmi(input, false_label); | 4361 __ JumpIfSmi(input, false_label); |
4352 if (!FLAG_harmony_typeof) { | 4362 if (!FLAG_harmony_typeof) { |
4353 __ CompareRoot(input, Heap::kNullValueRootIndex); | 4363 __ CompareRoot(input, Heap::kNullValueRootIndex); |
4354 __ b(eq, true_label); | 4364 __ b(eq, true_label); |
4355 } | 4365 } |
4356 __ CompareObjectType(input, input, scratch, | 4366 __ CompareObjectType(input, input, scratch, |
4357 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4367 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4358 __ b(lt, false_label); | 4368 __ b(lt, false_label); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4509 ASSERT(osr_pc_offset_ == -1); | 4519 ASSERT(osr_pc_offset_ == -1); |
4510 osr_pc_offset_ = masm()->pc_offset(); | 4520 osr_pc_offset_ = masm()->pc_offset(); |
4511 } | 4521 } |
4512 | 4522 |
4513 | 4523 |
4514 | 4524 |
4515 | 4525 |
4516 #undef __ | 4526 #undef __ |
4517 | 4527 |
4518 } } // namespace v8::internal | 4528 } } // namespace v8::internal |
OLD | NEW |