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

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

Issue 9572008: Implement date library functions in C++. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Bug fixes. 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
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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 template <> inline bool Is<JSFunction>(Object* obj) { 598 template <> inline bool Is<JSFunction>(Object* obj) {
599 return obj->IsJSFunction(); 599 return obj->IsJSFunction();
600 } 600 }
601 601
602 602
603 TYPE_CHECKER(Code, CODE_TYPE) 603 TYPE_CHECKER(Code, CODE_TYPE)
604 TYPE_CHECKER(Oddball, ODDBALL_TYPE) 604 TYPE_CHECKER(Oddball, ODDBALL_TYPE)
605 TYPE_CHECKER(JSGlobalPropertyCell, JS_GLOBAL_PROPERTY_CELL_TYPE) 605 TYPE_CHECKER(JSGlobalPropertyCell, JS_GLOBAL_PROPERTY_CELL_TYPE)
606 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) 606 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
607 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) 607 TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
608 TYPE_CHECKER(JSDate, JS_DATE_TYPE)
608 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) 609 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
609 610
610 611
611 bool Object::IsStringWrapper() { 612 bool Object::IsStringWrapper() {
612 return IsJSValue() && JSValue::cast(this)->value()->IsString(); 613 return IsJSValue() && JSValue::cast(this)->value()->IsString();
613 } 614 }
614 615
615 616
616 TYPE_CHECKER(Foreign, FOREIGN_TYPE) 617 TYPE_CHECKER(Foreign, FOREIGN_TYPE)
617 618
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 794
794 795
795 double Object::Number() { 796 double Object::Number() {
796 ASSERT(IsNumber()); 797 ASSERT(IsNumber());
797 return IsSmi() 798 return IsSmi()
798 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) 799 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value())
799 : reinterpret_cast<HeapNumber*>(this)->value(); 800 : reinterpret_cast<HeapNumber*>(this)->value();
800 } 801 }
801 802
802 803
804 bool Object::IsNaN() {
805 return this->IsHeapNumber() && isnan(HeapNumber::cast(this)->value());
806 }
807
808
803 MaybeObject* Object::ToSmi() { 809 MaybeObject* Object::ToSmi() {
804 if (IsSmi()) return this; 810 if (IsSmi()) return this;
805 if (IsHeapNumber()) { 811 if (IsHeapNumber()) {
806 double value = HeapNumber::cast(this)->value(); 812 double value = HeapNumber::cast(this)->value();
807 int int_value = FastD2I(value); 813 int int_value = FastD2I(value);
808 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 814 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
809 return Smi::FromInt(int_value); 815 return Smi::FromInt(int_value);
810 } 816 }
811 } 817 }
812 return Failure::Exception(); 818 return Failure::Exception();
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 case JS_GLOBAL_PROXY_TYPE: 1424 case JS_GLOBAL_PROXY_TYPE:
1419 return JSGlobalProxy::kSize; 1425 return JSGlobalProxy::kSize;
1420 case JS_GLOBAL_OBJECT_TYPE: 1426 case JS_GLOBAL_OBJECT_TYPE:
1421 return JSGlobalObject::kSize; 1427 return JSGlobalObject::kSize;
1422 case JS_BUILTINS_OBJECT_TYPE: 1428 case JS_BUILTINS_OBJECT_TYPE:
1423 return JSBuiltinsObject::kSize; 1429 return JSBuiltinsObject::kSize;
1424 case JS_FUNCTION_TYPE: 1430 case JS_FUNCTION_TYPE:
1425 return JSFunction::kSize; 1431 return JSFunction::kSize;
1426 case JS_VALUE_TYPE: 1432 case JS_VALUE_TYPE:
1427 return JSValue::kSize; 1433 return JSValue::kSize;
1434 case JS_DATE_TYPE:
1435 return JSDate::kSize;
1428 case JS_ARRAY_TYPE: 1436 case JS_ARRAY_TYPE:
1429 return JSArray::kSize; 1437 return JSArray::kSize;
1430 case JS_WEAK_MAP_TYPE: 1438 case JS_WEAK_MAP_TYPE:
1431 return JSWeakMap::kSize; 1439 return JSWeakMap::kSize;
1432 case JS_REGEXP_TYPE: 1440 case JS_REGEXP_TYPE:
1433 return JSRegExp::kSize; 1441 return JSRegExp::kSize;
1434 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: 1442 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
1435 return JSObject::kHeaderSize; 1443 return JSObject::kHeaderSize;
1436 case JS_MESSAGE_OBJECT_TYPE: 1444 case JS_MESSAGE_OBJECT_TYPE:
1437 return JSMessageObject::kSize; 1445 return JSMessageObject::kSize;
(...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 ACCESSORS(JSValue, value, Object, kValueOffset) 4119 ACCESSORS(JSValue, value, Object, kValueOffset)
4112 4120
4113 4121
4114 JSValue* JSValue::cast(Object* obj) { 4122 JSValue* JSValue::cast(Object* obj) {
4115 ASSERT(obj->IsJSValue()); 4123 ASSERT(obj->IsJSValue());
4116 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); 4124 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize);
4117 return reinterpret_cast<JSValue*>(obj); 4125 return reinterpret_cast<JSValue*>(obj);
4118 } 4126 }
4119 4127
4120 4128
4129 ACCESSORS(JSDate, value, Object, kValueOffset)
4130 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
4131 ACCESSORS(JSDate, year, Object, kYearOffset)
4132 ACCESSORS(JSDate, month, Object, kMonthOffset)
4133 ACCESSORS(JSDate, day, Object, kDayOffset)
4134 ACCESSORS(JSDate, hour, Object, kHourOffset)
4135 ACCESSORS(JSDate, min, Object, kMinOffset)
4136 ACCESSORS(JSDate, sec, Object, kSecOffset)
4137 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
rossberg 2012/03/06 15:55:50 Nit: reorder for consistency.
ulan 2012/03/07 10:55:21 Done.
4138
4139
4140 JSDate* JSDate::cast(Object* obj) {
4141 ASSERT(obj->IsJSDate());
4142 ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize);
4143 return reinterpret_cast<JSDate*>(obj);
4144 }
4145
4146
4121 ACCESSORS(JSMessageObject, type, String, kTypeOffset) 4147 ACCESSORS(JSMessageObject, type, String, kTypeOffset)
4122 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) 4148 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset)
4123 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) 4149 ACCESSORS(JSMessageObject, script, Object, kScriptOffset)
4124 ACCESSORS(JSMessageObject, stack_trace, Object, kStackTraceOffset) 4150 ACCESSORS(JSMessageObject, stack_trace, Object, kStackTraceOffset)
4125 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) 4151 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset)
4126 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) 4152 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset)
4127 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) 4153 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
4128 4154
4129 4155
4130 JSMessageObject* JSMessageObject::cast(Object* obj) { 4156 JSMessageObject* JSMessageObject::cast(Object* obj) {
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
4924 #undef WRITE_INT_FIELD 4950 #undef WRITE_INT_FIELD
4925 #undef READ_SHORT_FIELD 4951 #undef READ_SHORT_FIELD
4926 #undef WRITE_SHORT_FIELD 4952 #undef WRITE_SHORT_FIELD
4927 #undef READ_BYTE_FIELD 4953 #undef READ_BYTE_FIELD
4928 #undef WRITE_BYTE_FIELD 4954 #undef WRITE_BYTE_FIELD
4929 4955
4930 4956
4931 } } // namespace v8::internal 4957 } } // namespace v8::internal
4932 4958
4933 #endif // V8_OBJECTS_INL_H_ 4959 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698