OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 3775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3786 // If the object is not a value type, return the object. | 3786 // If the object is not a value type, return the object. |
3787 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx); | 3787 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx); |
3788 __ j(not_equal, &done); | 3788 __ j(not_equal, &done); |
3789 __ movp(rax, FieldOperand(rax, JSValue::kValueOffset)); | 3789 __ movp(rax, FieldOperand(rax, JSValue::kValueOffset)); |
3790 | 3790 |
3791 __ bind(&done); | 3791 __ bind(&done); |
3792 context()->Plug(rax); | 3792 context()->Plug(rax); |
3793 } | 3793 } |
3794 | 3794 |
3795 | 3795 |
| 3796 void FullCodeGenerator::EmitThrowIfNotADate(CallRuntime* expr) { |
| 3797 ZoneList<Expression*>* args = expr->arguments(); |
| 3798 DCHECK_EQ(1, args->length()); |
| 3799 |
| 3800 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 3801 |
| 3802 Register object = rax; |
| 3803 Register result = rax; |
| 3804 Register scratch = rcx; |
| 3805 |
| 3806 Label done, not_date_object; |
| 3807 __ JumpIfSmi(object, ¬_date_object, Label::kNear); |
| 3808 __ CmpObjectType(object, JS_DATE_TYPE, scratch); |
| 3809 __ j(equal, &done, Label::kNear); |
| 3810 __ bind(¬_date_object); |
| 3811 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
| 3812 |
| 3813 __ bind(&done); |
| 3814 context()->Plug(result); |
| 3815 } |
| 3816 |
| 3817 |
3796 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { | 3818 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
3797 ZoneList<Expression*>* args = expr->arguments(); | 3819 ZoneList<Expression*>* args = expr->arguments(); |
3798 DCHECK(args->length() == 2); | 3820 DCHECK(args->length() == 2); |
3799 DCHECK_NOT_NULL(args->at(1)->AsLiteral()); | 3821 DCHECK_NOT_NULL(args->at(1)->AsLiteral()); |
3800 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->value())); | 3822 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->value())); |
3801 | 3823 |
3802 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3824 VisitForAccumulatorValue(args->at(0)); // Load the object. |
3803 | 3825 |
3804 Label runtime, done, not_date_object; | |
3805 Register object = rax; | 3826 Register object = rax; |
3806 Register result = rax; | 3827 Register result = rax; |
3807 Register scratch = rcx; | 3828 Register scratch = rcx; |
3808 | 3829 |
3809 __ JumpIfSmi(object, ¬_date_object); | 3830 if (FLAG_debug_code) { |
3810 __ CmpObjectType(object, JS_DATE_TYPE, scratch); | 3831 __ AssertNotSmi(object); |
3811 __ j(not_equal, ¬_date_object); | 3832 __ CmpObjectType(object, JS_DATE_TYPE, scratch); |
| 3833 __ Check(equal, kOperandIsNotADate); |
| 3834 } |
3812 | 3835 |
3813 if (index->value() == 0) { | 3836 if (index->value() == 0) { |
3814 __ movp(result, FieldOperand(object, JSDate::kValueOffset)); | 3837 __ movp(result, FieldOperand(object, JSDate::kValueOffset)); |
3815 __ jmp(&done); | |
3816 } else { | 3838 } else { |
| 3839 Label runtime, done; |
3817 if (index->value() < JSDate::kFirstUncachedField) { | 3840 if (index->value() < JSDate::kFirstUncachedField) { |
3818 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); | 3841 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
3819 Operand stamp_operand = __ ExternalOperand(stamp); | 3842 Operand stamp_operand = __ ExternalOperand(stamp); |
3820 __ movp(scratch, stamp_operand); | 3843 __ movp(scratch, stamp_operand); |
3821 __ cmpp(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); | 3844 __ cmpp(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); |
3822 __ j(not_equal, &runtime, Label::kNear); | 3845 __ j(not_equal, &runtime, Label::kNear); |
3823 __ movp(result, FieldOperand(object, JSDate::kValueOffset + | 3846 __ movp(result, FieldOperand(object, JSDate::kValueOffset + |
3824 kPointerSize * index->value())); | 3847 kPointerSize * index->value())); |
3825 __ jmp(&done); | 3848 __ jmp(&done, Label::kNear); |
3826 } | 3849 } |
3827 __ bind(&runtime); | 3850 __ bind(&runtime); |
3828 __ PrepareCallCFunction(2); | 3851 __ PrepareCallCFunction(2); |
3829 __ movp(arg_reg_1, object); | 3852 __ movp(arg_reg_1, object); |
3830 __ Move(arg_reg_2, index, Assembler::RelocInfoNone()); | 3853 __ Move(arg_reg_2, index, Assembler::RelocInfoNone()); |
3831 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); | 3854 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
3832 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3855 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
3833 __ jmp(&done); | 3856 __ bind(&done); |
3834 } | 3857 } |
3835 | 3858 |
3836 __ bind(¬_date_object); | |
3837 __ CallRuntime(Runtime::kThrowNotDateError, 0); | |
3838 __ bind(&done); | |
3839 context()->Plug(rax); | 3859 context()->Plug(rax); |
3840 } | 3860 } |
3841 | 3861 |
3842 | 3862 |
3843 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3863 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
3844 ZoneList<Expression*>* args = expr->arguments(); | 3864 ZoneList<Expression*>* args = expr->arguments(); |
3845 DCHECK_EQ(3, args->length()); | 3865 DCHECK_EQ(3, args->length()); |
3846 | 3866 |
3847 Register string = rax; | 3867 Register string = rax; |
3848 Register index = rbx; | 3868 Register index = rbx; |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5479 Assembler::target_address_at(call_target_address, | 5499 Assembler::target_address_at(call_target_address, |
5480 unoptimized_code)); | 5500 unoptimized_code)); |
5481 return OSR_AFTER_STACK_CHECK; | 5501 return OSR_AFTER_STACK_CHECK; |
5482 } | 5502 } |
5483 | 5503 |
5484 | 5504 |
5485 } // namespace internal | 5505 } // namespace internal |
5486 } // namespace v8 | 5506 } // namespace v8 |
5487 | 5507 |
5488 #endif // V8_TARGET_ARCH_X64 | 5508 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |