OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 Condition is_smi = masm_->CheckSmi(value.reg()); | 3609 Condition is_smi = masm_->CheckSmi(value.reg()); |
3610 destination()->false_target()->Branch(is_smi); | 3610 destination()->false_target()->Branch(is_smi); |
3611 // It is a heap object - get map. | 3611 // It is a heap object - get map. |
3612 // Check if the object is a JS array or not. | 3612 // Check if the object is a JS array or not. |
3613 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, kScratchRegister); | 3613 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, kScratchRegister); |
3614 value.Unuse(); | 3614 value.Unuse(); |
3615 destination()->Split(equal); | 3615 destination()->Split(equal); |
3616 } | 3616 } |
3617 | 3617 |
3618 | 3618 |
| 3619 void CodeGenerator::GenerateIsObject(ZoneList<Expression*>* args) { |
| 3620 // This generates a fast version of: |
| 3621 // (typeof(arg) === 'object' || %_ClassOf(arg) == 'RegExp') |
| 3622 ASSERT(args->length() == 1); |
| 3623 Load(args->at(0)); |
| 3624 Result obj = frame_->Pop(); |
| 3625 obj.ToRegister(); |
| 3626 Condition is_smi = masm_->CheckSmi(obj.reg()); |
| 3627 destination()->false_target()->Branch(is_smi); |
| 3628 |
| 3629 __ Move(kScratchRegister, Factory::null_value()); |
| 3630 __ cmpq(obj.reg(), kScratchRegister); |
| 3631 destination()->true_target()->Branch(equal); |
| 3632 |
| 3633 __ movq(kScratchRegister, FieldOperand(obj.reg(), HeapObject::kMapOffset)); |
| 3634 // Undetectable objects behave like undefined when tested with typeof. |
| 3635 __ testb(FieldOperand(kScratchRegister, Map::kBitFieldOffset), |
| 3636 Immediate(1 << Map::kIsUndetectable)); |
| 3637 destination()->false_target()->Branch(not_zero); |
| 3638 __ CmpInstanceType(kScratchRegister, FIRST_JS_OBJECT_TYPE); |
| 3639 destination()->false_target()->Branch(less); |
| 3640 __ CmpInstanceType(kScratchRegister, LAST_JS_OBJECT_TYPE); |
| 3641 obj.Unuse(); |
| 3642 destination()->Split(less_equal); |
| 3643 } |
| 3644 |
| 3645 |
| 3646 void CodeGenerator::GenerateIsFunction(ZoneList<Expression*>* args) { |
| 3647 // This generates a fast version of: |
| 3648 // (%_ClassOf(arg) === 'Function') |
| 3649 ASSERT(args->length() == 1); |
| 3650 Load(args->at(0)); |
| 3651 Result obj = frame_->Pop(); |
| 3652 obj.ToRegister(); |
| 3653 Condition is_smi = masm_->CheckSmi(obj.reg()); |
| 3654 destination()->false_target()->Branch(is_smi); |
| 3655 __ CmpObjectType(obj.reg(), JS_FUNCTION_TYPE, kScratchRegister); |
| 3656 obj.Unuse(); |
| 3657 destination()->Split(equal); |
| 3658 } |
| 3659 |
| 3660 |
3619 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) { | 3661 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) { |
3620 ASSERT(args->length() == 0); | 3662 ASSERT(args->length() == 0); |
3621 | 3663 |
3622 // Get the frame pointer for the calling frame. | 3664 // Get the frame pointer for the calling frame. |
3623 Result fp = allocator()->Allocate(); | 3665 Result fp = allocator()->Allocate(); |
3624 __ movq(fp.reg(), Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 3666 __ movq(fp.reg(), Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
3625 | 3667 |
3626 // Skip the arguments adaptor frame if it exists. | 3668 // Skip the arguments adaptor frame if it exists. |
3627 Label check_frame_marker; | 3669 Label check_frame_marker; |
3628 __ SmiCompare(Operand(fp.reg(), StandardFrameConstants::kContextOffset), | 3670 __ SmiCompare(Operand(fp.reg(), StandardFrameConstants::kContextOffset), |
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7844 masm.GetCode(&desc); | 7886 masm.GetCode(&desc); |
7845 // Call the function from C++. | 7887 // Call the function from C++. |
7846 return FUNCTION_CAST<ModuloFunction>(buffer); | 7888 return FUNCTION_CAST<ModuloFunction>(buffer); |
7847 } | 7889 } |
7848 | 7890 |
7849 #endif | 7891 #endif |
7850 | 7892 |
7851 #undef __ | 7893 #undef __ |
7852 | 7894 |
7853 } } // namespace v8::internal | 7895 } } // namespace v8::internal |
OLD | NEW |