OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3029 | 3029 |
3030 | 3030 |
3031 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { | 3031 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
3032 ZoneList<Expression*>* args = expr->arguments(); | 3032 ZoneList<Expression*>* args = expr->arguments(); |
3033 ASSERT(args->length() == 2); | 3033 ASSERT(args->length() == 2); |
3034 ASSERT_NE(NULL, args->at(1)->AsLiteral()); | 3034 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
3035 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle())); | 3035 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle())); |
3036 | 3036 |
3037 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3037 VisitForAccumulatorValue(args->at(0)); // Load the object. |
3038 | 3038 |
3039 Label runtime, done; | 3039 Label runtime, done, not_date_object; |
3040 Register object = rax; | 3040 Register object = rax; |
3041 Register result = rax; | 3041 Register result = rax; |
3042 Register scratch = rcx; | 3042 Register scratch = rcx; |
3043 | 3043 |
3044 #ifdef DEBUG | 3044 __ JumpIfSmi(object, ¬_date_object); |
3045 __ AbortIfSmi(object); | |
3046 __ CmpObjectType(object, JS_DATE_TYPE, scratch); | 3045 __ CmpObjectType(object, JS_DATE_TYPE, scratch); |
3047 __ Assert(equal, "Trying to get date field from non-date."); | 3046 __ j(not_equal, ¬_date_object); |
3048 #endif | |
3049 | 3047 |
3050 if (index->value() == 0) { | 3048 if (index->value() == 0) { |
3051 __ movq(result, FieldOperand(object, JSDate::kValueOffset)); | 3049 __ movq(result, FieldOperand(object, JSDate::kValueOffset)); |
| 3050 __ jmp(&done); |
3052 } else { | 3051 } else { |
3053 if (index->value() < JSDate::kFirstUncachedField) { | 3052 if (index->value() < JSDate::kFirstUncachedField) { |
3054 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); | 3053 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
3055 __ movq(scratch, stamp); | 3054 __ movq(scratch, stamp); |
3056 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); | 3055 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); |
3057 __ j(not_equal, &runtime, Label::kNear); | 3056 __ j(not_equal, &runtime, Label::kNear); |
3058 __ movq(result, FieldOperand(object, JSDate::kValueOffset + | 3057 __ movq(result, FieldOperand(object, JSDate::kValueOffset + |
3059 kPointerSize * index->value())); | 3058 kPointerSize * index->value())); |
3060 __ jmp(&done); | 3059 __ jmp(&done); |
3061 } | 3060 } |
3062 __ bind(&runtime); | 3061 __ bind(&runtime); |
3063 __ PrepareCallCFunction(2); | 3062 __ PrepareCallCFunction(2); |
3064 #ifdef _WIN64 | 3063 #ifdef _WIN64 |
3065 __ movq(rcx, object); | 3064 __ movq(rcx, object); |
3066 __ movq(rdx, index, RelocInfo::NONE); | 3065 __ movq(rdx, index, RelocInfo::NONE); |
3067 #else | 3066 #else |
3068 __ movq(rdi, object); | 3067 __ movq(rdi, object); |
3069 __ movq(rsi, index, RelocInfo::NONE); | 3068 __ movq(rsi, index, RelocInfo::NONE); |
3070 #endif | 3069 #endif |
3071 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); | 3070 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
3072 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3071 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
3073 __ bind(&done); | 3072 __ jmp(&done); |
3074 } | 3073 } |
| 3074 |
| 3075 __ bind(¬_date_object); |
| 3076 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
| 3077 __ bind(&done); |
3075 context()->Plug(rax); | 3078 context()->Plug(rax); |
3076 } | 3079 } |
3077 | 3080 |
3078 | 3081 |
3079 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3082 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
3080 // Load the arguments on the stack and call the runtime function. | 3083 // Load the arguments on the stack and call the runtime function. |
3081 ZoneList<Expression*>* args = expr->arguments(); | 3084 ZoneList<Expression*>* args = expr->arguments(); |
3082 ASSERT(args->length() == 2); | 3085 ASSERT(args->length() == 2); |
3083 VisitForStackValue(args->at(0)); | 3086 VisitForStackValue(args->at(0)); |
3084 VisitForStackValue(args->at(1)); | 3087 VisitForStackValue(args->at(1)); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3488 | 3491 |
3489 context()->Plug(if_true, if_false); | 3492 context()->Plug(if_true, if_false); |
3490 } | 3493 } |
3491 | 3494 |
3492 | 3495 |
3493 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { | 3496 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { |
3494 ZoneList<Expression*>* args = expr->arguments(); | 3497 ZoneList<Expression*>* args = expr->arguments(); |
3495 ASSERT(args->length() == 1); | 3498 ASSERT(args->length() == 1); |
3496 VisitForAccumulatorValue(args->at(0)); | 3499 VisitForAccumulatorValue(args->at(0)); |
3497 | 3500 |
3498 if (generate_debug_code_) { | 3501 __ AbortIfNotString(rax); |
3499 __ AbortIfNotString(rax); | |
3500 } | |
3501 | 3502 |
3502 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); | 3503 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
3503 ASSERT(String::kHashShift >= kSmiTagSize); | 3504 ASSERT(String::kHashShift >= kSmiTagSize); |
3504 __ IndexFromHash(rax, rax); | 3505 __ IndexFromHash(rax, rax); |
3505 | 3506 |
3506 context()->Plug(rax); | 3507 context()->Plug(rax); |
3507 } | 3508 } |
3508 | 3509 |
3509 | 3510 |
3510 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { | 3511 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4552 *context_length = 0; | 4553 *context_length = 0; |
4553 return previous_; | 4554 return previous_; |
4554 } | 4555 } |
4555 | 4556 |
4556 | 4557 |
4557 #undef __ | 4558 #undef __ |
4558 | 4559 |
4559 } } // namespace v8::internal | 4560 } } // namespace v8::internal |
4560 | 4561 |
4561 #endif // V8_TARGET_ARCH_X64 | 4562 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |