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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 RELEASE_WRITE_FIELD( | 1483 RELEASE_WRITE_FIELD( |
1484 this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); | 1484 this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); |
1485 } | 1485 } |
1486 | 1486 |
1487 | 1487 |
1488 int HeapObject::Size() { | 1488 int HeapObject::Size() { |
1489 return SizeFromMap(map()); | 1489 return SizeFromMap(map()); |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 HeapObjectContents HeapObject::ContentType() { | |
1494 InstanceType type = map()->instance_type(); | |
1495 if (type <= LAST_NAME_TYPE) { | |
1496 if (type == SYMBOL_TYPE) { | |
1497 return HeapObjectContents::kTaggedValues; | |
1498 } | |
1499 DCHECK(type < FIRST_NONSTRING_TYPE); | |
1500 // There are four string representations: sequential strings, external | |
1501 // strings, cons strings, and sliced strings. | |
1502 // Only the former two contain raw values and no heap pointers (besides the | |
1503 // map-word). | |
1504 if (((type & kIsIndirectStringMask) != kIsIndirectStringTag)) | |
1505 return HeapObjectContents::kRawValues; | |
1506 else | |
1507 return HeapObjectContents::kTaggedValues; | |
1508 #if 0 | |
1509 // TODO(jochen): Enable eventually. | |
1510 } else if (type == JS_FUNCTION_TYPE) { | |
1511 return HeapObjectContents::kMixedValues; | |
1512 #endif | |
1513 } else if (type == BYTECODE_ARRAY_TYPE) { | |
1514 return HeapObjectContents::kMixedValues; | |
1515 } else if (type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | |
1516 type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | |
1517 return HeapObjectContents::kMixedValues; | |
1518 } else if (type == JS_ARRAY_BUFFER_TYPE) { | |
1519 return HeapObjectContents::kMixedValues; | |
1520 } else if (type <= LAST_DATA_TYPE) { | |
1521 // TODO(jochen): Why do we claim that Code and Map contain only raw values? | |
1522 return HeapObjectContents::kRawValues; | |
1523 } else { | |
1524 if (FLAG_unbox_double_fields) { | |
1525 LayoutDescriptorHelper helper(map()); | |
1526 if (!helper.all_fields_tagged()) return HeapObjectContents::kMixedValues; | |
1527 } | |
1528 return HeapObjectContents::kTaggedValues; | |
1529 } | |
1530 } | |
1531 | |
1532 | |
1533 double HeapNumber::value() const { | 1493 double HeapNumber::value() const { |
1534 return READ_DOUBLE_FIELD(this, kValueOffset); | 1494 return READ_DOUBLE_FIELD(this, kValueOffset); |
1535 } | 1495 } |
1536 | 1496 |
1537 | 1497 |
1538 void HeapNumber::set_value(double value) { | 1498 void HeapNumber::set_value(double value) { |
1539 WRITE_DOUBLE_FIELD(this, kValueOffset, value); | 1499 WRITE_DOUBLE_FIELD(this, kValueOffset, value); |
1540 } | 1500 } |
1541 | 1501 |
1542 | 1502 |
(...skipping 6379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7922 #undef WRITE_INT64_FIELD | 7882 #undef WRITE_INT64_FIELD |
7923 #undef READ_BYTE_FIELD | 7883 #undef READ_BYTE_FIELD |
7924 #undef WRITE_BYTE_FIELD | 7884 #undef WRITE_BYTE_FIELD |
7925 #undef NOBARRIER_READ_BYTE_FIELD | 7885 #undef NOBARRIER_READ_BYTE_FIELD |
7926 #undef NOBARRIER_WRITE_BYTE_FIELD | 7886 #undef NOBARRIER_WRITE_BYTE_FIELD |
7927 | 7887 |
7928 } // namespace internal | 7888 } // namespace internal |
7929 } // namespace v8 | 7889 } // namespace v8 |
7930 | 7890 |
7931 #endif // V8_OBJECTS_INL_H_ | 7891 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |