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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // - JSSet | 57 // - JSSet |
58 // - JSMap | 58 // - JSMap |
59 // - JSWeakMap | 59 // - JSWeakMap |
60 // - JSRegExp | 60 // - JSRegExp |
61 // - JSFunction | 61 // - JSFunction |
62 // - GlobalObject | 62 // - GlobalObject |
63 // - JSGlobalObject | 63 // - JSGlobalObject |
64 // - JSBuiltinsObject | 64 // - JSBuiltinsObject |
65 // - JSGlobalProxy | 65 // - JSGlobalProxy |
66 // - JSValue | 66 // - JSValue |
67 // - JSDate | |
67 // - JSMessageObject | 68 // - JSMessageObject |
68 // - JSProxy | 69 // - JSProxy |
69 // - JSFunctionProxy | 70 // - JSFunctionProxy |
70 // - FixedArrayBase | 71 // - FixedArrayBase |
71 // - ByteArray | 72 // - ByteArray |
72 // - FixedArray | 73 // - FixedArray |
73 // - DescriptorArray | 74 // - DescriptorArray |
74 // - HashTable | 75 // - HashTable |
75 // - Dictionary | 76 // - Dictionary |
76 // - SymbolTable | 77 // - SymbolTable |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 V(CODE_CACHE_TYPE) \ | 294 V(CODE_CACHE_TYPE) \ |
294 V(POLYMORPHIC_CODE_CACHE_TYPE) \ | 295 V(POLYMORPHIC_CODE_CACHE_TYPE) \ |
295 \ | 296 \ |
296 V(FIXED_ARRAY_TYPE) \ | 297 V(FIXED_ARRAY_TYPE) \ |
297 V(FIXED_DOUBLE_ARRAY_TYPE) \ | 298 V(FIXED_DOUBLE_ARRAY_TYPE) \ |
298 V(SHARED_FUNCTION_INFO_TYPE) \ | 299 V(SHARED_FUNCTION_INFO_TYPE) \ |
299 \ | 300 \ |
300 V(JS_MESSAGE_OBJECT_TYPE) \ | 301 V(JS_MESSAGE_OBJECT_TYPE) \ |
301 \ | 302 \ |
302 V(JS_VALUE_TYPE) \ | 303 V(JS_VALUE_TYPE) \ |
304 V(JS_DATE_TYPE) \ | |
303 V(JS_OBJECT_TYPE) \ | 305 V(JS_OBJECT_TYPE) \ |
304 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ | 306 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ |
305 V(JS_GLOBAL_OBJECT_TYPE) \ | 307 V(JS_GLOBAL_OBJECT_TYPE) \ |
306 V(JS_BUILTINS_OBJECT_TYPE) \ | 308 V(JS_BUILTINS_OBJECT_TYPE) \ |
307 V(JS_GLOBAL_PROXY_TYPE) \ | 309 V(JS_GLOBAL_PROXY_TYPE) \ |
308 V(JS_ARRAY_TYPE) \ | 310 V(JS_ARRAY_TYPE) \ |
309 V(JS_PROXY_TYPE) \ | 311 V(JS_PROXY_TYPE) \ |
310 V(JS_WEAK_MAP_TYPE) \ | 312 V(JS_WEAK_MAP_TYPE) \ |
311 V(JS_REGEXP_TYPE) \ | 313 V(JS_REGEXP_TYPE) \ |
312 \ | 314 \ |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 | 614 |
613 // All the following types are subtypes of JSReceiver, which corresponds to | 615 // All the following types are subtypes of JSReceiver, which corresponds to |
614 // objects in the JS sense. The first and the last type in this range are | 616 // objects in the JS sense. The first and the last type in this range are |
615 // the two forms of function. This organization enables using the same | 617 // the two forms of function. This organization enables using the same |
616 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the | 618 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the |
617 // NONCALLABLE_JS_OBJECT range. | 619 // NONCALLABLE_JS_OBJECT range. |
618 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE | 620 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE |
619 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE | 621 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE |
620 | 622 |
621 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE | 623 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE |
624 JS_DATE_TYPE, | |
622 JS_OBJECT_TYPE, | 625 JS_OBJECT_TYPE, |
623 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 626 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
624 JS_GLOBAL_OBJECT_TYPE, | 627 JS_GLOBAL_OBJECT_TYPE, |
625 JS_BUILTINS_OBJECT_TYPE, | 628 JS_BUILTINS_OBJECT_TYPE, |
626 JS_GLOBAL_PROXY_TYPE, | 629 JS_GLOBAL_PROXY_TYPE, |
627 JS_ARRAY_TYPE, | 630 JS_ARRAY_TYPE, |
628 JS_SET_TYPE, | 631 JS_SET_TYPE, |
629 JS_MAP_TYPE, | 632 JS_MAP_TYPE, |
630 JS_WEAK_MAP_TYPE, | 633 JS_WEAK_MAP_TYPE, |
631 | 634 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 V(FixedArray) \ | 809 V(FixedArray) \ |
807 V(FixedDoubleArray) \ | 810 V(FixedDoubleArray) \ |
808 V(Context) \ | 811 V(Context) \ |
809 V(GlobalContext) \ | 812 V(GlobalContext) \ |
810 V(ScopeInfo) \ | 813 V(ScopeInfo) \ |
811 V(JSFunction) \ | 814 V(JSFunction) \ |
812 V(Code) \ | 815 V(Code) \ |
813 V(Oddball) \ | 816 V(Oddball) \ |
814 V(SharedFunctionInfo) \ | 817 V(SharedFunctionInfo) \ |
815 V(JSValue) \ | 818 V(JSValue) \ |
819 V(JSDate) \ | |
816 V(JSMessageObject) \ | 820 V(JSMessageObject) \ |
817 V(StringWrapper) \ | 821 V(StringWrapper) \ |
818 V(Foreign) \ | 822 V(Foreign) \ |
819 V(Boolean) \ | 823 V(Boolean) \ |
820 V(JSArray) \ | 824 V(JSArray) \ |
821 V(JSProxy) \ | 825 V(JSProxy) \ |
822 V(JSFunctionProxy) \ | 826 V(JSFunctionProxy) \ |
823 V(JSSet) \ | 827 V(JSSet) \ |
824 V(JSMap) \ | 828 V(JSMap) \ |
825 V(JSWeakMap) \ | 829 V(JSWeakMap) \ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
880 INLINE(bool IsTrue()); | 884 INLINE(bool IsTrue()); |
881 INLINE(bool IsFalse()); | 885 INLINE(bool IsFalse()); |
882 inline bool IsArgumentsMarker(); | 886 inline bool IsArgumentsMarker(); |
883 inline bool NonFailureIsHeapObject(); | 887 inline bool NonFailureIsHeapObject(); |
884 | 888 |
885 // Filler objects (fillers and free space objects). | 889 // Filler objects (fillers and free space objects). |
886 inline bool IsFiller(); | 890 inline bool IsFiller(); |
887 | 891 |
888 // Extract the number. | 892 // Extract the number. |
889 inline double Number(); | 893 inline double Number(); |
894 inline bool IsNaN(); | |
890 | 895 |
891 // Returns true if the object is of the correct type to be used as a | 896 // Returns true if the object is of the correct type to be used as a |
892 // implementation of a JSObject's elements. | 897 // implementation of a JSObject's elements. |
893 inline bool HasValidElements(); | 898 inline bool HasValidElements(); |
894 | 899 |
895 inline bool HasSpecificClassOf(String* name); | 900 inline bool HasSpecificClassOf(String* name); |
896 | 901 |
897 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. | 902 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. |
898 Object* ToBoolean(); // ECMA-262 9.2. | 903 Object* ToBoolean(); // ECMA-262 9.2. |
899 | 904 |
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5965 | 5970 |
5966 static int OffsetOfCodeWithId(Builtins::JavaScript id) { | 5971 static int OffsetOfCodeWithId(Builtins::JavaScript id) { |
5967 return kJSBuiltinsCodeOffset + id * kPointerSize; | 5972 return kJSBuiltinsCodeOffset + id * kPointerSize; |
5968 } | 5973 } |
5969 | 5974 |
5970 private: | 5975 private: |
5971 DISALLOW_IMPLICIT_CONSTRUCTORS(JSBuiltinsObject); | 5976 DISALLOW_IMPLICIT_CONSTRUCTORS(JSBuiltinsObject); |
5972 }; | 5977 }; |
5973 | 5978 |
5974 | 5979 |
5975 // Representation for JS Wrapper objects, String, Number, Boolean, Date, etc. | 5980 // Representation for JS Wrapper objects, String, Number, Boolean, etc. |
5976 class JSValue: public JSObject { | 5981 class JSValue: public JSObject { |
5977 public: | 5982 public: |
5978 // [value]: the object being wrapped. | 5983 // [value]: the object being wrapped. |
5979 DECL_ACCESSORS(value, Object) | 5984 DECL_ACCESSORS(value, Object) |
5980 | 5985 |
5981 // Casting. | 5986 // Casting. |
5982 static inline JSValue* cast(Object* obj); | 5987 static inline JSValue* cast(Object* obj); |
5983 | 5988 |
5984 // Dispatched behavior. | 5989 // Dispatched behavior. |
5985 #ifdef OBJECT_PRINT | 5990 #ifdef OBJECT_PRINT |
5986 inline void JSValuePrint() { | 5991 inline void JSValuePrint() { |
5987 JSValuePrint(stdout); | 5992 JSValuePrint(stdout); |
5988 } | 5993 } |
5989 void JSValuePrint(FILE* out); | 5994 void JSValuePrint(FILE* out); |
5990 #endif | 5995 #endif |
5991 #ifdef DEBUG | 5996 #ifdef DEBUG |
5992 void JSValueVerify(); | 5997 void JSValueVerify(); |
5993 #endif | 5998 #endif |
5994 | 5999 |
5995 // Layout description. | 6000 // Layout description. |
5996 static const int kValueOffset = JSObject::kHeaderSize; | 6001 static const int kValueOffset = JSObject::kHeaderSize; |
5997 static const int kSize = kValueOffset + kPointerSize; | 6002 static const int kSize = kValueOffset + kPointerSize; |
5998 | 6003 |
5999 private: | 6004 private: |
6000 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); | 6005 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); |
6001 }; | 6006 }; |
6002 | 6007 |
6003 | 6008 |
6009 class DateCache; | |
6010 | |
6011 // Representation for JS date objects. | |
6012 class JSDate: public JSObject { | |
6013 public: | |
6014 // If one component is NaN, all of them are, indicating a NaN time value. | |
6015 // [value]: the time value. | |
6016 DECL_ACCESSORS(value, Object) | |
6017 // [year]: caches year. Either undefined, smi, or NaN. | |
6018 DECL_ACCESSORS(year, Object) | |
6019 // [month]: caches month. Either undefined, smi, or NaN. | |
6020 DECL_ACCESSORS(month, Object) | |
6021 // [day]: caches day. Either undefined, smi, or NaN. | |
6022 DECL_ACCESSORS(day, Object) | |
6023 // [weekday]: caches day of week. Either undefined, smi, or NaN. | |
6024 DECL_ACCESSORS(weekday, Object) | |
6025 // [hour]: caches hours. Either undefined, smi, or NaN. | |
6026 DECL_ACCESSORS(hour, Object) | |
6027 // [min]: caches minutes. Either undefined, smi, or NaN. | |
6028 DECL_ACCESSORS(min, Object) | |
6029 // [sec]: caches seconds. Either undefined, smi, or NaN. | |
6030 DECL_ACCESSORS(sec, Object) | |
6031 // [cache stamp]: sample of the date cache stamp at the | |
6032 // moment when local fields were cached. | |
6033 DECL_ACCESSORS(cache_stamp, Object) | |
6034 | |
6035 // Casting. | |
6036 static inline JSDate* cast(Object* obj); | |
6037 | |
6038 // Returns the date field with the specified index. | |
6039 // See FieldIndex for the list of date fields. | |
6040 static MaybeObject* GetField(Object* date, Smi* index); | |
rossberg
2012/03/06 15:55:50
Why is this a static method?
And why not give inde
ulan
2012/03/07 10:55:21
It is called from generated code and the index is
| |
6041 | |
6042 void SetValue(Object* value, bool is_value_nan); | |
rossberg
2012/03/06 15:55:50
I would remove the redundant flag parameter and ju
ulan
2012/03/07 10:55:21
This would cost us redundant operations.
| |
6043 | |
6044 | |
6045 // Dispatched behavior. | |
6046 #ifdef OBJECT_PRINT | |
6047 inline void JSDatePrint() { | |
6048 JSDatePrint(stdout); | |
6049 } | |
6050 void JSDatePrint(FILE* out); | |
6051 #endif | |
6052 #ifdef DEBUG | |
6053 void JSDateVerify(); | |
6054 #endif | |
6055 // The order is important. It must be kept in sync with date macros | |
6056 // in macros.py. | |
6057 enum FieldIndex { | |
6058 kDateValue, | |
6059 kYear, | |
6060 kMonth, | |
6061 kDay, | |
6062 kWeekday, | |
6063 kHour, | |
6064 kMinute, | |
6065 kSecond, | |
6066 kFirstUncachedField, | |
6067 kMillisecond = kFirstUncachedField, | |
6068 kDays, | |
6069 kTimeInDay, | |
6070 kFirstUTCField, | |
6071 kYearUTC = kFirstUTCField, | |
6072 kMonthUTC, | |
6073 kDayUTC, | |
6074 kWeekdayUTC, | |
6075 kHourUTC, | |
6076 kMinuteUTC, | |
6077 kSecondUTC, | |
6078 kMillisecondUTC, | |
6079 kDaysUTC, | |
6080 kTimeInDayUTC, | |
6081 kTimezoneOffset | |
6082 }; | |
6083 | |
6084 // Layout description. | |
6085 static const int kValueOffset = JSObject::kHeaderSize; | |
6086 static const int kYearOffset = kValueOffset + kPointerSize; | |
6087 static const int kMonthOffset = kYearOffset + kPointerSize; | |
6088 static const int kDayOffset = kMonthOffset + kPointerSize; | |
6089 static const int kWeekdayOffset = kDayOffset + kPointerSize; | |
6090 static const int kHourOffset = kWeekdayOffset + kPointerSize; | |
6091 static const int kMinOffset = kHourOffset + kPointerSize; | |
6092 static const int kSecOffset = kMinOffset + kPointerSize; | |
6093 static const int kCacheStampOffset = kSecOffset + kPointerSize; | |
6094 static const int kSize = kCacheStampOffset + kPointerSize; | |
6095 | |
6096 private: | |
6097 inline Object* DoGetField(FieldIndex index); | |
6098 | |
6099 Object* GetUTCField(FieldIndex index, double value, DateCache* date_cache); | |
6100 | |
6101 // Computes and caches the cacheable fields of the date. | |
6102 inline void SetLocalFields(int64_t local_time_ms, DateCache* date_cache); | |
6103 | |
6104 | |
6105 DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate); | |
6106 }; | |
6107 | |
6108 | |
6004 // Representation of message objects used for error reporting through | 6109 // Representation of message objects used for error reporting through |
6005 // the API. The messages are formatted in JavaScript so this object is | 6110 // the API. The messages are formatted in JavaScript so this object is |
6006 // a real JavaScript object. The information used for formatting the | 6111 // a real JavaScript object. The information used for formatting the |
6007 // error messages are not directly accessible from JavaScript to | 6112 // error messages are not directly accessible from JavaScript to |
6008 // prevent leaking information to user code called during error | 6113 // prevent leaking information to user code called during error |
6009 // formatting. | 6114 // formatting. |
6010 class JSMessageObject: public JSObject { | 6115 class JSMessageObject: public JSObject { |
6011 public: | 6116 public: |
6012 // [type]: the type of error message. | 6117 // [type]: the type of error message. |
6013 DECL_ACCESSORS(type, String) | 6118 DECL_ACCESSORS(type, String) |
(...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8423 } else { | 8528 } else { |
8424 value &= ~(1 << bit_position); | 8529 value &= ~(1 << bit_position); |
8425 } | 8530 } |
8426 return value; | 8531 return value; |
8427 } | 8532 } |
8428 }; | 8533 }; |
8429 | 8534 |
8430 } } // namespace v8::internal | 8535 } } // namespace v8::internal |
8431 | 8536 |
8432 #endif // V8_OBJECTS_H_ | 8537 #endif // V8_OBJECTS_H_ |
OLD | NEW |