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 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2941 // If the object is not a value type, return the object. | 2941 // If the object is not a value type, return the object. |
2942 __ CmpObjectType(eax, JS_VALUE_TYPE, ebx); | 2942 __ CmpObjectType(eax, JS_VALUE_TYPE, ebx); |
2943 __ j(not_equal, &done, Label::kNear); | 2943 __ j(not_equal, &done, Label::kNear); |
2944 __ mov(eax, FieldOperand(eax, JSValue::kValueOffset)); | 2944 __ mov(eax, FieldOperand(eax, JSValue::kValueOffset)); |
2945 | 2945 |
2946 __ bind(&done); | 2946 __ bind(&done); |
2947 context()->Plug(eax); | 2947 context()->Plug(eax); |
2948 } | 2948 } |
2949 | 2949 |
2950 | 2950 |
| 2951 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
| 2952 ZoneList<Expression*>* args = expr->arguments(); |
| 2953 ASSERT(args->length() == 2); |
| 2954 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
| 2955 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle())); |
| 2956 |
| 2957 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 2958 |
| 2959 Label runtime, done; |
| 2960 Register object = eax; |
| 2961 Register result = eax; |
| 2962 Register scratch = ecx; |
| 2963 |
| 2964 #ifdef DEBUG |
| 2965 __ AbortIfSmi(object); |
| 2966 __ CmpObjectType(object, JS_DATE_TYPE, scratch); |
| 2967 __ Assert(equal, "Trying to get date field from non-date."); |
| 2968 #endif |
| 2969 |
| 2970 if (index->value() == 0) { |
| 2971 __ mov(result, FieldOperand(object, JSDate::kValueOffset)); |
| 2972 } else { |
| 2973 if (index->value() < JSDate::kFirstUncachedField) { |
| 2974 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
| 2975 __ mov(scratch, Operand::StaticVariable(stamp)); |
| 2976 __ cmp(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); |
| 2977 __ j(not_equal, &runtime, Label::kNear); |
| 2978 __ mov(result, FieldOperand(object, JSDate::kValueOffset + |
| 2979 kPointerSize * index->value())); |
| 2980 __ jmp(&done); |
| 2981 } |
| 2982 __ bind(&runtime); |
| 2983 __ PrepareCallCFunction(2, scratch); |
| 2984 __ mov(Operand(esp, 0), object); |
| 2985 __ mov(Operand(esp, 1 * kPointerSize), Immediate(index)); |
| 2986 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
| 2987 __ bind(&done); |
| 2988 } |
| 2989 context()->Plug(result); |
| 2990 } |
| 2991 |
| 2992 |
2951 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 2993 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
2952 // Load the arguments on the stack and call the runtime function. | 2994 // Load the arguments on the stack and call the runtime function. |
2953 ZoneList<Expression*>* args = expr->arguments(); | 2995 ZoneList<Expression*>* args = expr->arguments(); |
2954 ASSERT(args->length() == 2); | 2996 ASSERT(args->length() == 2); |
2955 VisitForStackValue(args->at(0)); | 2997 VisitForStackValue(args->at(0)); |
2956 VisitForStackValue(args->at(1)); | 2998 VisitForStackValue(args->at(1)); |
2957 | 2999 |
2958 if (CpuFeatures::IsSupported(SSE2)) { | 3000 if (CpuFeatures::IsSupported(SSE2)) { |
2959 MathPowStub stub(MathPowStub::ON_STACK); | 3001 MathPowStub stub(MathPowStub::ON_STACK); |
2960 __ CallStub(&stub); | 3002 __ CallStub(&stub); |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4453 *context_length = 0; | 4495 *context_length = 0; |
4454 return previous_; | 4496 return previous_; |
4455 } | 4497 } |
4456 | 4498 |
4457 | 4499 |
4458 #undef __ | 4500 #undef __ |
4459 | 4501 |
4460 } } // namespace v8::internal | 4502 } } // namespace v8::internal |
4461 | 4503 |
4462 #endif // V8_TARGET_ARCH_IA32 | 4504 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |