OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 644 } |
645 | 645 |
646 Vector<const char> string_; | 646 Vector<const char> string_; |
647 uint32_t hash_field_; | 647 uint32_t hash_field_; |
648 int chars_; // Caches the number of characters when computing the hash code. | 648 int chars_; // Caches the number of characters when computing the hash code. |
649 uint32_t seed_; | 649 uint32_t seed_; |
650 }; | 650 }; |
651 | 651 |
652 | 652 |
653 bool Object::IsNumber() const { | 653 bool Object::IsNumber() const { |
654 return IsSmi() || IsHeapNumber(); | 654 return IsSmi() || HeapObject::cast(this)->IsHeapNumber(); |
655 } | 655 } |
656 | 656 |
657 | 657 |
658 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) | 658 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) |
659 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE) | 659 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE) |
660 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) | 660 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
661 | 661 |
662 bool HeapObject::IsFiller() const { | 662 bool HeapObject::IsFiller() const { |
663 InstanceType instance_type = map()->instance_type(); | 663 InstanceType instance_type = map()->instance_type(); |
664 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 664 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 return ConvertToName(isolate, input); | 1074 return ConvertToName(isolate, input); |
1075 } | 1075 } |
1076 | 1076 |
1077 // static | 1077 // static |
1078 MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input, | 1078 MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input, |
1079 ToPrimitiveHint hint) { | 1079 ToPrimitiveHint hint) { |
1080 if (input->IsPrimitive()) return input; | 1080 if (input->IsPrimitive()) return input; |
1081 return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint); | 1081 return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint); |
1082 } | 1082 } |
1083 | 1083 |
| 1084 // static |
| 1085 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) { |
| 1086 if (input->IsNumber()) return input; |
| 1087 return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input); |
| 1088 } |
| 1089 |
| 1090 // static |
| 1091 MaybeHandle<Object> Object::ToInteger(Isolate* isolate, Handle<Object> input) { |
| 1092 if (input->IsSmi()) return input; |
| 1093 return ConvertToInteger(isolate, input); |
| 1094 } |
| 1095 |
| 1096 // static |
| 1097 MaybeHandle<Object> Object::ToInt32(Isolate* isolate, Handle<Object> input) { |
| 1098 if (input->IsSmi()) return input; |
| 1099 return ConvertToInt32(isolate, input); |
| 1100 } |
| 1101 |
| 1102 // static |
| 1103 MaybeHandle<Object> Object::ToUint32(Isolate* isolate, Handle<Object> input) { |
| 1104 if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate); |
| 1105 return ConvertToUint32(isolate, input); |
| 1106 } |
| 1107 |
| 1108 // static |
| 1109 MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) { |
| 1110 if (input->IsString()) return Handle<String>::cast(input); |
| 1111 return ConvertToString(isolate, input); |
| 1112 } |
1084 | 1113 |
1085 bool Object::HasSpecificClassOf(String* name) { | 1114 bool Object::HasSpecificClassOf(String* name) { |
1086 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); | 1115 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); |
1087 } | 1116 } |
1088 | 1117 |
1089 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, | 1118 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, |
1090 Handle<Name> name) { | 1119 Handle<Name> name) { |
1091 LookupIterator it(object, name); | 1120 LookupIterator it(object, name); |
1092 if (!it.IsFound()) return it.factory()->undefined_value(); | 1121 if (!it.IsFound()) return it.factory()->undefined_value(); |
1093 return GetProperty(&it); | 1122 return GetProperty(&it); |
(...skipping 7391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8485 #undef WRITE_INT64_FIELD | 8514 #undef WRITE_INT64_FIELD |
8486 #undef READ_BYTE_FIELD | 8515 #undef READ_BYTE_FIELD |
8487 #undef WRITE_BYTE_FIELD | 8516 #undef WRITE_BYTE_FIELD |
8488 #undef NOBARRIER_READ_BYTE_FIELD | 8517 #undef NOBARRIER_READ_BYTE_FIELD |
8489 #undef NOBARRIER_WRITE_BYTE_FIELD | 8518 #undef NOBARRIER_WRITE_BYTE_FIELD |
8490 | 8519 |
8491 } // namespace internal | 8520 } // namespace internal |
8492 } // namespace v8 | 8521 } // namespace v8 |
8493 | 8522 |
8494 #endif // V8_OBJECTS_INL_H_ | 8523 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |