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

Side by Side Diff: src/objects.h

Issue 9572008: Implement date library functions in C++. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase 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/macros.py ('k') | src/objects.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 6010 matching lines...) Expand 10 before | Expand all | Expand 10 after
6021 6021
6022 // Layout description. 6022 // Layout description.
6023 static const int kValueOffset = JSObject::kHeaderSize; 6023 static const int kValueOffset = JSObject::kHeaderSize;
6024 static const int kSize = kValueOffset + kPointerSize; 6024 static const int kSize = kValueOffset + kPointerSize;
6025 6025
6026 private: 6026 private:
6027 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); 6027 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue);
6028 }; 6028 };
6029 6029
6030 6030
6031 class DateCache;
6032
6031 // Representation for JS date objects. 6033 // Representation for JS date objects.
6032 class JSDate: public JSObject { 6034 class JSDate: public JSObject {
6033 public: 6035 public:
6034 // If one component is NaN, all of them are, indicating a NaN time value. 6036 // If one component is NaN, all of them are, indicating a NaN time value.
6035 // [value]: the time value. 6037 // [value]: the time value.
6036 DECL_ACCESSORS(value, Object) 6038 DECL_ACCESSORS(value, Object)
6037 // [local]: the offset for the local time value.
6038 DECL_ACCESSORS(local, Object)
6039 // [year]: caches year. Either undefined, smi, or NaN. 6039 // [year]: caches year. Either undefined, smi, or NaN.
6040 DECL_ACCESSORS(year, Object) 6040 DECL_ACCESSORS(year, Object)
6041 // [month]: caches month. Either undefined, smi, or NaN. 6041 // [month]: caches month. Either undefined, smi, or NaN.
6042 DECL_ACCESSORS(month, Object) 6042 DECL_ACCESSORS(month, Object)
6043 // [day]: caches day. Either undefined, smi, or NaN. 6043 // [day]: caches day. Either undefined, smi, or NaN.
6044 DECL_ACCESSORS(day, Object) 6044 DECL_ACCESSORS(day, Object)
6045 // [weekday]: caches day of week. Either undefined, smi, or NaN.
6046 DECL_ACCESSORS(weekday, Object)
6045 // [hour]: caches hours. Either undefined, smi, or NaN. 6047 // [hour]: caches hours. Either undefined, smi, or NaN.
6046 DECL_ACCESSORS(hour, Object) 6048 DECL_ACCESSORS(hour, Object)
6047 // [min]: caches minutes. Either undefined, smi, or NaN. 6049 // [min]: caches minutes. Either undefined, smi, or NaN.
6048 DECL_ACCESSORS(min, Object) 6050 DECL_ACCESSORS(min, Object)
6049 // [sec]: caches seconds. Either undefined, smi, or NaN. 6051 // [sec]: caches seconds. Either undefined, smi, or NaN.
6050 DECL_ACCESSORS(sec, Object) 6052 DECL_ACCESSORS(sec, Object)
6051 // [weekday]: caches day of week. Either undefined, smi, or NaN. 6053 // [cache stamp]: sample of the date cache stamp at the
6052 DECL_ACCESSORS(weekday, Object) 6054 // moment when local fields were cached.
6055 DECL_ACCESSORS(cache_stamp, Object)
6053 6056
6054 // Casting. 6057 // Casting.
6055 static inline JSDate* cast(Object* obj); 6058 static inline JSDate* cast(Object* obj);
6056 6059
6060 // Returns the date field with the specified index.
6061 // See FieldIndex for the list of date fields.
6062 static MaybeObject* GetField(Object* date, Smi* index);
6063
6064 void SetValue(Object* value, bool is_value_nan);
6065
6066
6057 // Dispatched behavior. 6067 // Dispatched behavior.
6058 #ifdef OBJECT_PRINT 6068 #ifdef OBJECT_PRINT
6059 inline void JSDatePrint() { 6069 inline void JSDatePrint() {
6060 JSDatePrint(stdout); 6070 JSDatePrint(stdout);
6061 } 6071 }
6062 void JSDatePrint(FILE* out); 6072 void JSDatePrint(FILE* out);
6063 #endif 6073 #endif
6064 #ifdef DEBUG 6074 #ifdef DEBUG
6065 void JSDateVerify(); 6075 void JSDateVerify();
6066 #endif 6076 #endif
6077 // The order is important. It must be kept in sync with date macros
6078 // in macros.py.
6079 enum FieldIndex {
6080 kDateValue,
6081 kYear,
6082 kMonth,
6083 kDay,
6084 kWeekday,
6085 kHour,
6086 kMinute,
6087 kSecond,
6088 kFirstUncachedField,
6089 kMillisecond = kFirstUncachedField,
6090 kDays,
6091 kTimeInDay,
6092 kFirstUTCField,
6093 kYearUTC = kFirstUTCField,
6094 kMonthUTC,
6095 kDayUTC,
6096 kWeekdayUTC,
6097 kHourUTC,
6098 kMinuteUTC,
6099 kSecondUTC,
6100 kMillisecondUTC,
6101 kDaysUTC,
6102 kTimeInDayUTC,
6103 kTimezoneOffset
6104 };
6067 6105
6068 // Layout description. 6106 // Layout description.
6069 static const int kValueOffset = JSObject::kHeaderSize; 6107 static const int kValueOffset = JSObject::kHeaderSize;
6070 static const int kLocalOffset = kValueOffset + kPointerSize; 6108 static const int kYearOffset = kValueOffset + kPointerSize;
6071 static const int kYearOffset = kLocalOffset + kPointerSize;
6072 static const int kMonthOffset = kYearOffset + kPointerSize; 6109 static const int kMonthOffset = kYearOffset + kPointerSize;
6073 static const int kDayOffset = kMonthOffset + kPointerSize; 6110 static const int kDayOffset = kMonthOffset + kPointerSize;
6074 static const int kHourOffset = kDayOffset + kPointerSize; 6111 static const int kWeekdayOffset = kDayOffset + kPointerSize;
6112 static const int kHourOffset = kWeekdayOffset + kPointerSize;
6075 static const int kMinOffset = kHourOffset + kPointerSize; 6113 static const int kMinOffset = kHourOffset + kPointerSize;
6076 static const int kSecOffset = kMinOffset + kPointerSize; 6114 static const int kSecOffset = kMinOffset + kPointerSize;
6077 static const int kWeekdayOffset = kSecOffset + kPointerSize; 6115 static const int kCacheStampOffset = kSecOffset + kPointerSize;
6078 static const int kSize = kWeekdayOffset + kPointerSize; 6116 static const int kSize = kCacheStampOffset + kPointerSize;
6079
6080 // Index of first field not requiring a write barrier.
6081 static const int kFirstBarrierFree = 2; // year
6082 6117
6083 private: 6118 private:
6119 inline Object* DoGetField(FieldIndex index);
6120
6121 Object* GetUTCField(FieldIndex index, double value, DateCache* date_cache);
6122
6123 // Computes and caches the cacheable fields of the date.
6124 inline void SetLocalFields(int64_t local_time_ms, DateCache* date_cache);
6125
6126
6084 DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate); 6127 DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate);
6085 }; 6128 };
6086 6129
6087 6130
6088 // Representation of message objects used for error reporting through 6131 // Representation of message objects used for error reporting through
6089 // the API. The messages are formatted in JavaScript so this object is 6132 // the API. The messages are formatted in JavaScript so this object is
6090 // a real JavaScript object. The information used for formatting the 6133 // a real JavaScript object. The information used for formatting the
6091 // error messages are not directly accessible from JavaScript to 6134 // error messages are not directly accessible from JavaScript to
6092 // prevent leaking information to user code called during error 6135 // prevent leaking information to user code called during error
6093 // formatting. 6136 // formatting.
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after
8528 } else { 8571 } else {
8529 value &= ~(1 << bit_position); 8572 value &= ~(1 << bit_position);
8530 } 8573 }
8531 return value; 8574 return value;
8532 } 8575 }
8533 }; 8576 };
8534 8577
8535 } } // namespace v8::internal 8578 } } // namespace v8::internal
8536 8579
8537 #endif // V8_OBJECTS_H_ 8580 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/macros.py ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698