| 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 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3649 UnaryOperation* left_unary = left->AsUnaryOperation(); | 3649 UnaryOperation* left_unary = left->AsUnaryOperation(); |
| 3650 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; | 3650 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; |
| 3651 Handle<String> check = Handle<String>::cast(right_literal_value); | 3651 Handle<String> check = Handle<String>::cast(right_literal_value); |
| 3652 | 3652 |
| 3653 { AccumulatorValueContext context(this); | 3653 { AccumulatorValueContext context(this); |
| 3654 VisitForTypeofValue(left_unary->expression()); | 3654 VisitForTypeofValue(left_unary->expression()); |
| 3655 } | 3655 } |
| 3656 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3656 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 3657 | 3657 |
| 3658 if (check->Equals(isolate()->heap()->number_symbol())) { | 3658 if (check->Equals(isolate()->heap()->number_symbol())) { |
| 3659 Condition is_smi = masm_->CheckSmi(rax); | 3659 __ JumpIfSmi(rax, if_true); |
| 3660 __ j(is_smi, if_true); | |
| 3661 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); | 3660 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); |
| 3662 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex); | 3661 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex); |
| 3663 Split(equal, if_true, if_false, fall_through); | 3662 Split(equal, if_true, if_false, fall_through); |
| 3664 } else if (check->Equals(isolate()->heap()->string_symbol())) { | 3663 } else if (check->Equals(isolate()->heap()->string_symbol())) { |
| 3665 Condition is_smi = masm_->CheckSmi(rax); | 3664 __ JumpIfSmi(rax, if_false); |
| 3666 __ j(is_smi, if_false); | |
| 3667 // Check for undetectable objects => false. | 3665 // Check for undetectable objects => false. |
| 3668 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 3666 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx); |
| 3667 __ j(above_equal, if_false); |
| 3669 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3668 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
| 3670 Immediate(1 << Map::kIsUndetectable)); | 3669 Immediate(1 << Map::kIsUndetectable)); |
| 3671 __ j(not_zero, if_false); | 3670 Split(zero, if_true, if_false, fall_through); |
| 3672 __ CmpInstanceType(rdx, FIRST_NONSTRING_TYPE); | |
| 3673 Split(below, if_true, if_false, fall_through); | |
| 3674 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { | 3671 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { |
| 3675 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 3672 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
| 3676 __ j(equal, if_true); | 3673 __ j(equal, if_true); |
| 3677 __ CompareRoot(rax, Heap::kFalseValueRootIndex); | 3674 __ CompareRoot(rax, Heap::kFalseValueRootIndex); |
| 3678 Split(equal, if_true, if_false, fall_through); | 3675 Split(equal, if_true, if_false, fall_through); |
| 3679 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { | 3676 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { |
| 3680 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 3677 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 3681 __ j(equal, if_true); | 3678 __ j(equal, if_true); |
| 3682 Condition is_smi = masm_->CheckSmi(rax); | 3679 __ JumpIfSmi(rax, if_false); |
| 3683 __ j(is_smi, if_false); | |
| 3684 // Check for undetectable objects => true. | 3680 // Check for undetectable objects => true. |
| 3685 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 3681 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 3686 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3682 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
| 3687 Immediate(1 << Map::kIsUndetectable)); | 3683 Immediate(1 << Map::kIsUndetectable)); |
| 3688 Split(not_zero, if_true, if_false, fall_through); | 3684 Split(not_zero, if_true, if_false, fall_through); |
| 3689 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 3685 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 3690 Condition is_smi = masm_->CheckSmi(rax); | 3686 __ JumpIfSmi(rax, if_false); |
| 3691 __ j(is_smi, if_false); | 3687 __ CmpObjectType(rax, FIRST_FUNCTION_CLASS_TYPE, rdx); |
| 3692 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rdx); | 3688 Split(above_equal, if_true, if_false, fall_through); |
| 3693 __ j(equal, if_true); | |
| 3694 // Regular expressions => 'function' (they are callable). | |
| 3695 __ CmpInstanceType(rdx, JS_REGEXP_TYPE); | |
| 3696 Split(equal, if_true, if_false, fall_through); | |
| 3697 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 3689 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 3698 Condition is_smi = masm_->CheckSmi(rax); | 3690 __ JumpIfSmi(rax, if_false); |
| 3699 __ j(is_smi, if_false); | |
| 3700 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 3691 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
| 3701 __ j(equal, if_true); | 3692 __ j(equal, if_true); |
| 3702 // Regular expressions => 'function', not 'object'. | 3693 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdx); |
| 3703 __ CmpObjectType(rax, JS_REGEXP_TYPE, rdx); | 3694 __ j(below, if_false); |
| 3704 __ j(equal, if_false); | 3695 __ CmpInstanceType(rdx, FIRST_FUNCTION_CLASS_TYPE); |
| 3696 __ j(above_equal, if_false); |
| 3705 // Check for undetectable objects => false. | 3697 // Check for undetectable objects => false. |
| 3706 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3698 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
| 3707 Immediate(1 << Map::kIsUndetectable)); | 3699 Immediate(1 << Map::kIsUndetectable)); |
| 3708 __ j(not_zero, if_false); | 3700 Split(zero, if_true, if_false, fall_through); |
| 3709 // Check for JS objects => true. | |
| 3710 __ CmpInstanceType(rdx, FIRST_JS_OBJECT_TYPE); | |
| 3711 __ j(below, if_false); | |
| 3712 __ CmpInstanceType(rdx, LAST_JS_OBJECT_TYPE); | |
| 3713 Split(below_equal, if_true, if_false, fall_through); | |
| 3714 } else { | 3701 } else { |
| 3715 if (if_false != fall_through) __ jmp(if_false); | 3702 if (if_false != fall_through) __ jmp(if_false); |
| 3716 } | 3703 } |
| 3717 | 3704 |
| 3718 return true; | 3705 return true; |
| 3719 } | 3706 } |
| 3720 | 3707 |
| 3721 | 3708 |
| 3722 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 3709 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 3723 Comment cmnt(masm_, "[ CompareOperation"); | 3710 Comment cmnt(masm_, "[ CompareOperation"); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3991 __ ret(0); | 3978 __ ret(0); |
| 3992 } | 3979 } |
| 3993 | 3980 |
| 3994 | 3981 |
| 3995 #undef __ | 3982 #undef __ |
| 3996 | 3983 |
| 3997 | 3984 |
| 3998 } } // namespace v8::internal | 3985 } } // namespace v8::internal |
| 3999 | 3986 |
| 4000 #endif // V8_TARGET_ARCH_X64 | 3987 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |