Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: src/objects-inl.h

Issue 9307083: Implement caching scheme for Date fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased to HEAD. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 794
795 795
796 double Object::Number() { 796 double Object::Number() {
797 ASSERT(IsNumber()); 797 ASSERT(IsNumber());
798 return IsSmi() 798 return IsSmi()
799 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) 799 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value())
800 : reinterpret_cast<HeapNumber*>(this)->value(); 800 : reinterpret_cast<HeapNumber*>(this)->value();
801 } 801 }
802 802
803 803
804 bool Object::IsNaN() {
805 return this->IsHeapNumber() && isnan(HeapNumber::cast(this)->value());
806 }
807
808
804 MaybeObject* Object::ToSmi() { 809 MaybeObject* Object::ToSmi() {
805 if (IsSmi()) return this; 810 if (IsSmi()) return this;
806 if (IsHeapNumber()) { 811 if (IsHeapNumber()) {
807 double value = HeapNumber::cast(this)->value(); 812 double value = HeapNumber::cast(this)->value();
808 int int_value = FastD2I(value); 813 int int_value = FastD2I(value);
809 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 814 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
810 return Smi::FromInt(int_value); 815 return Smi::FromInt(int_value);
811 } 816 }
812 } 817 }
813 return Failure::Exception(); 818 return Failure::Exception();
(...skipping 3302 matching lines...) Expand 10 before | Expand all | Expand 10 after
4116 4121
4117 4122
4118 JSValue* JSValue::cast(Object* obj) { 4123 JSValue* JSValue::cast(Object* obj) {
4119 ASSERT(obj->IsJSValue()); 4124 ASSERT(obj->IsJSValue());
4120 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); 4125 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize);
4121 return reinterpret_cast<JSValue*>(obj); 4126 return reinterpret_cast<JSValue*>(obj);
4122 } 4127 }
4123 4128
4124 4129
4125 ACCESSORS(JSDate, value, Object, kValueOffset) 4130 ACCESSORS(JSDate, value, Object, kValueOffset)
4131 ACCESSORS(JSDate, local, Object, kLocalOffset)
4126 ACCESSORS(JSDate, year, Object, kYearOffset) 4132 ACCESSORS(JSDate, year, Object, kYearOffset)
4127 ACCESSORS(JSDate, month, Object, kMonthOffset) 4133 ACCESSORS(JSDate, month, Object, kMonthOffset)
4128 ACCESSORS(JSDate, day, Object, kDayOffset) 4134 ACCESSORS(JSDate, day, Object, kDayOffset)
4129 ACCESSORS(JSDate, hour, Object, kHourOffset) 4135 ACCESSORS(JSDate, hour, Object, kHourOffset)
4130 ACCESSORS(JSDate, min, Object, kMinOffset) 4136 ACCESSORS(JSDate, min, Object, kMinOffset)
4131 ACCESSORS(JSDate, sec, Object, kSecOffset) 4137 ACCESSORS(JSDate, sec, Object, kSecOffset)
4132 ACCESSORS(JSDate, ms, Object, kMsOffset) 4138 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
4133 4139
4134 4140
4135 JSDate* JSDate::cast(Object* obj) { 4141 JSDate* JSDate::cast(Object* obj) {
4136 ASSERT(obj->IsJSDate()); 4142 ASSERT(obj->IsJSDate());
4137 ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize); 4143 ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize);
4138 return reinterpret_cast<JSDate*>(obj); 4144 return reinterpret_cast<JSDate*>(obj);
4139 } 4145 }
4140 4146
4141 4147
4142 ACCESSORS(JSMessageObject, type, String, kTypeOffset) 4148 ACCESSORS(JSMessageObject, type, String, kTypeOffset)
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 #undef WRITE_INT_FIELD 4951 #undef WRITE_INT_FIELD
4946 #undef READ_SHORT_FIELD 4952 #undef READ_SHORT_FIELD
4947 #undef WRITE_SHORT_FIELD 4953 #undef WRITE_SHORT_FIELD
4948 #undef READ_BYTE_FIELD 4954 #undef READ_BYTE_FIELD
4949 #undef WRITE_BYTE_FIELD 4955 #undef WRITE_BYTE_FIELD
4950 4956
4951 4957
4952 } } // namespace v8::internal 4958 } } // namespace v8::internal
4953 4959
4954 #endif // V8_OBJECTS_INL_H_ 4960 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698