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 3622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3633 UnaryOperation* left_unary = left->AsUnaryOperation(); | 3633 UnaryOperation* left_unary = left->AsUnaryOperation(); |
3634 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; | 3634 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; |
3635 Handle<String> check = Handle<String>::cast(right_literal_value); | 3635 Handle<String> check = Handle<String>::cast(right_literal_value); |
3636 | 3636 |
3637 { AccumulatorValueContext context(this); | 3637 { AccumulatorValueContext context(this); |
3638 VisitForTypeofValue(left_unary->expression()); | 3638 VisitForTypeofValue(left_unary->expression()); |
3639 } | 3639 } |
3640 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3640 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
3641 | 3641 |
3642 if (check->Equals(Heap::number_symbol())) { | 3642 if (check->Equals(Heap::number_symbol())) { |
3643 Condition is_smi = masm_->CheckSmi(rax); | 3643 __ JumpIfSmi(rax, if_true); |
3644 __ j(is_smi, if_true); | |
3645 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); | 3644 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); |
3646 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex); | 3645 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex); |
3647 Split(equal, if_true, if_false, fall_through); | 3646 Split(equal, if_true, if_false, fall_through); |
3648 } else if (check->Equals(Heap::string_symbol())) { | 3647 } else if (check->Equals(Heap::string_symbol())) { |
3649 Condition is_smi = masm_->CheckSmi(rax); | 3648 __ JumpIfSmi(rax, if_false); |
3650 __ j(is_smi, if_false); | |
3651 // Check for undetectable objects => false. | 3649 // Check for undetectable objects => false. |
3652 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 3650 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx); |
| 3651 __ j(above_equal, if_false); |
3653 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3652 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
3654 Immediate(1 << Map::kIsUndetectable)); | 3653 Immediate(1 << Map::kIsUndetectable)); |
3655 __ j(not_zero, if_false); | 3654 Split(zero, if_true, if_false, fall_through); |
3656 __ CmpInstanceType(rdx, FIRST_NONSTRING_TYPE); | |
3657 Split(below, if_true, if_false, fall_through); | |
3658 } else if (check->Equals(Heap::boolean_symbol())) { | 3655 } else if (check->Equals(Heap::boolean_symbol())) { |
3659 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 3656 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
3660 __ j(equal, if_true); | 3657 __ j(equal, if_true); |
3661 __ CompareRoot(rax, Heap::kFalseValueRootIndex); | 3658 __ CompareRoot(rax, Heap::kFalseValueRootIndex); |
3662 Split(equal, if_true, if_false, fall_through); | 3659 Split(equal, if_true, if_false, fall_through); |
3663 } else if (check->Equals(Heap::undefined_symbol())) { | 3660 } else if (check->Equals(Heap::undefined_symbol())) { |
3664 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 3661 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
3665 __ j(equal, if_true); | 3662 __ j(equal, if_true); |
3666 Condition is_smi = masm_->CheckSmi(rax); | 3663 __ JumpIfSmi(rax, if_false); |
3667 __ j(is_smi, if_false); | |
3668 // Check for undetectable objects => true. | 3664 // Check for undetectable objects => true. |
3669 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 3665 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
3670 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3666 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
3671 Immediate(1 << Map::kIsUndetectable)); | 3667 Immediate(1 << Map::kIsUndetectable)); |
3672 Split(not_zero, if_true, if_false, fall_through); | 3668 Split(not_zero, if_true, if_false, fall_through); |
3673 } else if (check->Equals(Heap::function_symbol())) { | 3669 } else if (check->Equals(Heap::function_symbol())) { |
3674 Condition is_smi = masm_->CheckSmi(rax); | 3670 __ JumpIfSmi(rax, if_false); |
3675 __ j(is_smi, if_false); | 3671 __ CmpObjectType(rax, FIRST_FUNCTION_CLASS_TYPE, rdx); |
3676 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rdx); | 3672 Split(above_equal, if_true, if_false, fall_through); |
3677 __ j(equal, if_true); | |
3678 // Regular expressions => 'function' (they are callable). | |
3679 __ CmpInstanceType(rdx, JS_REGEXP_TYPE); | |
3680 Split(equal, if_true, if_false, fall_through); | |
3681 } else if (check->Equals(Heap::object_symbol())) { | 3673 } else if (check->Equals(Heap::object_symbol())) { |
3682 Condition is_smi = masm_->CheckSmi(rax); | 3674 __ JumpIfSmi(rax, if_false); |
3683 __ j(is_smi, if_false); | |
3684 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 3675 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
3685 __ j(equal, if_true); | 3676 __ j(equal, if_true); |
3686 // Regular expressions => 'function', not 'object'. | 3677 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdx); |
3687 __ CmpObjectType(rax, JS_REGEXP_TYPE, rdx); | 3678 __ j(below, if_false); |
3688 __ j(equal, if_false); | 3679 __ CmpInstanceType(rdx, FIRST_FUNCTION_CLASS_TYPE); |
| 3680 __ j(above_equal, if_false); |
3689 // Check for undetectable objects => false. | 3681 // Check for undetectable objects => false. |
3690 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3682 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
3691 Immediate(1 << Map::kIsUndetectable)); | 3683 Immediate(1 << Map::kIsUndetectable)); |
3692 __ j(not_zero, if_false); | 3684 Split(zero, if_true, if_false, fall_through); |
3693 // Check for JS objects => true. | |
3694 __ CmpInstanceType(rdx, FIRST_JS_OBJECT_TYPE); | |
3695 __ j(below, if_false); | |
3696 __ CmpInstanceType(rdx, LAST_JS_OBJECT_TYPE); | |
3697 Split(below_equal, if_true, if_false, fall_through); | |
3698 } else { | 3685 } else { |
3699 if (if_false != fall_through) __ jmp(if_false); | 3686 if (if_false != fall_through) __ jmp(if_false); |
3700 } | 3687 } |
3701 | 3688 |
3702 return true; | 3689 return true; |
3703 } | 3690 } |
3704 | 3691 |
3705 | 3692 |
3706 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 3693 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
3707 Comment cmnt(masm_, "[ CompareOperation"); | 3694 Comment cmnt(masm_, "[ CompareOperation"); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3975 __ ret(0); | 3962 __ ret(0); |
3976 } | 3963 } |
3977 | 3964 |
3978 | 3965 |
3979 #undef __ | 3966 #undef __ |
3980 | 3967 |
3981 | 3968 |
3982 } } // namespace v8::internal | 3969 } } // namespace v8::internal |
3983 | 3970 |
3984 #endif // V8_TARGET_ARCH_X64 | 3971 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |