| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 bool Object::IsSymbolTable() { | 557 bool Object::IsSymbolTable() { |
| 558 return IsHashTable() && this == Heap::raw_unchecked_symbol_table(); | 558 return IsHashTable() && this == Heap::raw_unchecked_symbol_table(); |
| 559 } | 559 } |
| 560 | 560 |
| 561 | 561 |
| 562 bool Object::IsCompilationCacheTable() { | 562 bool Object::IsCompilationCacheTable() { |
| 563 return IsHashTable(); | 563 return IsHashTable(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 | 566 |
| 567 bool Object::IsCodeCacheHashTable() { |
| 568 return IsHashTable(); |
| 569 } |
| 570 |
| 571 |
| 567 bool Object::IsMapCache() { | 572 bool Object::IsMapCache() { |
| 568 return IsHashTable(); | 573 return IsHashTable(); |
| 569 } | 574 } |
| 570 | 575 |
| 571 | 576 |
| 572 bool Object::IsPrimitive() { | 577 bool Object::IsPrimitive() { |
| 573 return IsOddball() || IsNumber() || IsString(); | 578 return IsOddball() || IsNumber() || IsString(); |
| 574 } | 579 } |
| 575 | 580 |
| 576 | 581 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 return Construct(EXCEPTION); | 838 return Construct(EXCEPTION); |
| 834 } | 839 } |
| 835 | 840 |
| 836 | 841 |
| 837 Failure* Failure::OutOfMemoryException() { | 842 Failure* Failure::OutOfMemoryException() { |
| 838 return Construct(OUT_OF_MEMORY_EXCEPTION); | 843 return Construct(OUT_OF_MEMORY_EXCEPTION); |
| 839 } | 844 } |
| 840 | 845 |
| 841 | 846 |
| 842 intptr_t Failure::value() const { | 847 intptr_t Failure::value() const { |
| 843 return reinterpret_cast<intptr_t>(this) >> kFailureTagSize; | 848 return static_cast<intptr_t>( |
| 849 reinterpret_cast<uintptr_t>(this) >> kFailureTagSize); |
| 844 } | 850 } |
| 845 | 851 |
| 846 | 852 |
| 847 Failure* Failure::RetryAfterGC(int requested_bytes) { | 853 Failure* Failure::RetryAfterGC(int requested_bytes) { |
| 848 // Assert that the space encoding fits in the three bytes allotted for it. | 854 // Assert that the space encoding fits in the three bytes allotted for it. |
| 849 ASSERT((LAST_SPACE & ~kSpaceTagMask) == 0); | 855 ASSERT((LAST_SPACE & ~kSpaceTagMask) == 0); |
| 850 intptr_t requested = requested_bytes >> kObjectAlignmentBits; | 856 uintptr_t requested = |
| 851 int tag_bits = kSpaceTagSize + kFailureTypeTagSize; | 857 static_cast<uintptr_t>(requested_bytes >> kObjectAlignmentBits); |
| 858 int tag_bits = kSpaceTagSize + kFailureTypeTagSize + kFailureTagSize; |
| 852 if (((requested << tag_bits) >> tag_bits) != requested) { | 859 if (((requested << tag_bits) >> tag_bits) != requested) { |
| 853 // No room for entire requested size in the bits. Round down to | 860 // No room for entire requested size in the bits. Round down to |
| 854 // maximally representable size. | 861 // maximally representable size. |
| 855 requested = static_cast<intptr_t>( | 862 requested = static_cast<intptr_t>( |
| 856 (~static_cast<uintptr_t>(0)) >> (tag_bits + 1)); | 863 (~static_cast<uintptr_t>(0)) >> (tag_bits + 1)); |
| 857 } | 864 } |
| 858 int value = static_cast<int>(requested << kSpaceTagSize) | NEW_SPACE; | 865 int value = static_cast<int>(requested << kSpaceTagSize) | NEW_SPACE; |
| 859 return Construct(RETRY_AFTER_GC, value); | 866 return Construct(RETRY_AFTER_GC, value); |
| 860 } | 867 } |
| 861 | 868 |
| 862 | 869 |
| 863 Failure* Failure::Construct(Type type, intptr_t value) { | 870 Failure* Failure::Construct(Type type, intptr_t value) { |
| 864 intptr_t info = (static_cast<intptr_t>(value) << kFailureTypeTagSize) | type; | 871 uintptr_t info = |
| 872 (static_cast<uintptr_t>(value) << kFailureTypeTagSize) | type; |
| 865 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); | 873 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); |
| 866 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); | 874 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); |
| 867 } | 875 } |
| 868 | 876 |
| 869 | 877 |
| 870 bool Smi::IsValid(intptr_t value) { | 878 bool Smi::IsValid(intptr_t value) { |
| 871 #ifdef DEBUG | 879 #ifdef DEBUG |
| 872 bool in_range = (value >= kMinValue) && (value <= kMaxValue); | 880 bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
| 873 #endif | 881 #endif |
| 874 | 882 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 } | 1395 } |
| 1388 | 1396 |
| 1389 | 1397 |
| 1390 void FixedArray::set_the_hole(int index) { | 1398 void FixedArray::set_the_hole(int index) { |
| 1391 ASSERT(index >= 0 && index < this->length()); | 1399 ASSERT(index >= 0 && index < this->length()); |
| 1392 ASSERT(!Heap::InNewSpace(Heap::the_hole_value())); | 1400 ASSERT(!Heap::InNewSpace(Heap::the_hole_value())); |
| 1393 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, Heap::the_hole_value()); | 1401 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, Heap::the_hole_value()); |
| 1394 } | 1402 } |
| 1395 | 1403 |
| 1396 | 1404 |
| 1405 Object** FixedArray::data_start() { |
| 1406 return HeapObject::RawField(this, kHeaderSize); |
| 1407 } |
| 1408 |
| 1409 |
| 1397 bool DescriptorArray::IsEmpty() { | 1410 bool DescriptorArray::IsEmpty() { |
| 1398 ASSERT(this == Heap::empty_descriptor_array() || | 1411 ASSERT(this == Heap::empty_descriptor_array() || |
| 1399 this->length() > 2); | 1412 this->length() > 2); |
| 1400 return this == Heap::empty_descriptor_array(); | 1413 return this == Heap::empty_descriptor_array(); |
| 1401 } | 1414 } |
| 1402 | 1415 |
| 1403 | 1416 |
| 1404 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { | 1417 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { |
| 1405 Object* tmp = array->get(first); | 1418 Object* tmp = array->get(first); |
| 1406 fast_set(array, first, array->get(second)); | 1419 fast_set(array, first, array->get(second)); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 | 1566 |
| 1554 | 1567 |
| 1555 // ------------------------------------ | 1568 // ------------------------------------ |
| 1556 // Cast operations | 1569 // Cast operations |
| 1557 | 1570 |
| 1558 | 1571 |
| 1559 CAST_ACCESSOR(FixedArray) | 1572 CAST_ACCESSOR(FixedArray) |
| 1560 CAST_ACCESSOR(DescriptorArray) | 1573 CAST_ACCESSOR(DescriptorArray) |
| 1561 CAST_ACCESSOR(SymbolTable) | 1574 CAST_ACCESSOR(SymbolTable) |
| 1562 CAST_ACCESSOR(CompilationCacheTable) | 1575 CAST_ACCESSOR(CompilationCacheTable) |
| 1576 CAST_ACCESSOR(CodeCacheHashTable) |
| 1563 CAST_ACCESSOR(MapCache) | 1577 CAST_ACCESSOR(MapCache) |
| 1564 CAST_ACCESSOR(String) | 1578 CAST_ACCESSOR(String) |
| 1565 CAST_ACCESSOR(SeqString) | 1579 CAST_ACCESSOR(SeqString) |
| 1566 CAST_ACCESSOR(SeqAsciiString) | 1580 CAST_ACCESSOR(SeqAsciiString) |
| 1567 CAST_ACCESSOR(SeqTwoByteString) | 1581 CAST_ACCESSOR(SeqTwoByteString) |
| 1568 CAST_ACCESSOR(ConsString) | 1582 CAST_ACCESSOR(ConsString) |
| 1569 CAST_ACCESSOR(ExternalString) | 1583 CAST_ACCESSOR(ExternalString) |
| 1570 CAST_ACCESSOR(ExternalAsciiString) | 1584 CAST_ACCESSOR(ExternalAsciiString) |
| 1571 CAST_ACCESSOR(ExternalTwoByteString) | 1585 CAST_ACCESSOR(ExternalTwoByteString) |
| 1572 CAST_ACCESSOR(JSObject) | 1586 CAST_ACCESSOR(JSObject) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 | 1644 |
| 1631 bool String::Equals(String* other) { | 1645 bool String::Equals(String* other) { |
| 1632 if (other == this) return true; | 1646 if (other == this) return true; |
| 1633 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { | 1647 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { |
| 1634 return false; | 1648 return false; |
| 1635 } | 1649 } |
| 1636 return SlowEquals(other); | 1650 return SlowEquals(other); |
| 1637 } | 1651 } |
| 1638 | 1652 |
| 1639 | 1653 |
| 1640 Object* String::TryFlattenIfNotFlat() { | 1654 Object* String::TryFlatten(PretenureFlag pretenure) { |
| 1641 // We don't need to flatten strings that are already flat. Since this code | 1655 // We don't need to flatten strings that are already flat. Since this code |
| 1642 // is inlined, it can be helpful in the flat case to not call out to Flatten. | 1656 // is inlined, it can be helpful in the flat case to not call out to Flatten. |
| 1643 if (!IsFlat()) { | 1657 if (IsFlat()) return this; |
| 1644 return TryFlatten(); | 1658 return SlowTryFlatten(pretenure); |
| 1645 } | |
| 1646 return this; | |
| 1647 } | 1659 } |
| 1648 | 1660 |
| 1649 | 1661 |
| 1650 uint16_t String::Get(int index) { | 1662 uint16_t String::Get(int index) { |
| 1651 ASSERT(index >= 0 && index < length()); | 1663 ASSERT(index >= 0 && index < length()); |
| 1652 switch (StringShape(this).full_representation_tag()) { | 1664 switch (StringShape(this).full_representation_tag()) { |
| 1653 case kSeqStringTag | kAsciiStringTag: | 1665 case kSeqStringTag | kAsciiStringTag: |
| 1654 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 1666 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
| 1655 case kSeqStringTag | kTwoByteStringTag: | 1667 case kSeqStringTag | kTwoByteStringTag: |
| 1656 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 1668 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 } | 2148 } |
| 2137 | 2149 |
| 2138 | 2150 |
| 2139 int Code::arguments_count() { | 2151 int Code::arguments_count() { |
| 2140 ASSERT(is_call_stub() || kind() == STUB); | 2152 ASSERT(is_call_stub() || kind() == STUB); |
| 2141 return ExtractArgumentsCountFromFlags(flags()); | 2153 return ExtractArgumentsCountFromFlags(flags()); |
| 2142 } | 2154 } |
| 2143 | 2155 |
| 2144 | 2156 |
| 2145 CodeStub::Major Code::major_key() { | 2157 CodeStub::Major Code::major_key() { |
| 2146 ASSERT(kind() == STUB); | 2158 ASSERT(kind() == STUB || kind() == BINARY_OP_IC); |
| 2147 return static_cast<CodeStub::Major>(READ_BYTE_FIELD(this, | 2159 return static_cast<CodeStub::Major>(READ_BYTE_FIELD(this, |
| 2148 kStubMajorKeyOffset)); | 2160 kStubMajorKeyOffset)); |
| 2149 } | 2161 } |
| 2150 | 2162 |
| 2151 | 2163 |
| 2152 void Code::set_major_key(CodeStub::Major major) { | 2164 void Code::set_major_key(CodeStub::Major major) { |
| 2153 ASSERT(kind() == STUB); | 2165 ASSERT(kind() == STUB || kind() == BINARY_OP_IC); |
| 2154 ASSERT(0 <= major && major < 256); | 2166 ASSERT(0 <= major && major < 256); |
| 2155 WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major); | 2167 WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major); |
| 2156 } | 2168 } |
| 2157 | 2169 |
| 2158 | 2170 |
| 2159 bool Code::is_inline_cache_stub() { | 2171 bool Code::is_inline_cache_stub() { |
| 2160 Kind kind = this->kind(); | 2172 Kind kind = this->kind(); |
| 2161 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; | 2173 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; |
| 2162 } | 2174 } |
| 2163 | 2175 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 | 2257 |
| 2246 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 2258 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 2247 ASSERT(value->IsNull() || value->IsJSObject()); | 2259 ASSERT(value->IsNull() || value->IsJSObject()); |
| 2248 WRITE_FIELD(this, kPrototypeOffset, value); | 2260 WRITE_FIELD(this, kPrototypeOffset, value); |
| 2249 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode); | 2261 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode); |
| 2250 } | 2262 } |
| 2251 | 2263 |
| 2252 | 2264 |
| 2253 ACCESSORS(Map, instance_descriptors, DescriptorArray, | 2265 ACCESSORS(Map, instance_descriptors, DescriptorArray, |
| 2254 kInstanceDescriptorsOffset) | 2266 kInstanceDescriptorsOffset) |
| 2255 ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset) | 2267 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
| 2256 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 2268 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
| 2257 | 2269 |
| 2258 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 2270 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
| 2259 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 2271 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) |
| 2260 | 2272 |
| 2261 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 2273 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
| 2262 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 2274 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
| 2263 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 2275 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
| 2264 | 2276 |
| 2265 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) | 2277 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 kStartPositionAndTypeOffset) | 2395 kStartPositionAndTypeOffset) |
| 2384 INT_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) | 2396 INT_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) |
| 2385 INT_ACCESSORS(SharedFunctionInfo, function_token_position, | 2397 INT_ACCESSORS(SharedFunctionInfo, function_token_position, |
| 2386 kFunctionTokenPositionOffset) | 2398 kFunctionTokenPositionOffset) |
| 2387 INT_ACCESSORS(SharedFunctionInfo, compiler_hints, | 2399 INT_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| 2388 kCompilerHintsOffset) | 2400 kCompilerHintsOffset) |
| 2389 INT_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, | 2401 INT_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, |
| 2390 kThisPropertyAssignmentsCountOffset) | 2402 kThisPropertyAssignmentsCountOffset) |
| 2391 | 2403 |
| 2392 | 2404 |
| 2405 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) |
| 2406 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) |
| 2407 |
| 2393 bool Script::HasValidSource() { | 2408 bool Script::HasValidSource() { |
| 2394 Object* src = this->source(); | 2409 Object* src = this->source(); |
| 2395 if (!src->IsString()) return true; | 2410 if (!src->IsString()) return true; |
| 2396 String* src_str = String::cast(src); | 2411 String* src_str = String::cast(src); |
| 2397 if (!StringShape(src_str).IsExternal()) return true; | 2412 if (!StringShape(src_str).IsExternal()) return true; |
| 2398 if (src_str->IsAsciiRepresentation()) { | 2413 if (src_str->IsAsciiRepresentation()) { |
| 2399 return ExternalAsciiString::cast(src)->resource() != NULL; | 2414 return ExternalAsciiString::cast(src)->resource() != NULL; |
| 2400 } else if (src_str->IsTwoByteRepresentation()) { | 2415 } else if (src_str->IsTwoByteRepresentation()) { |
| 2401 return ExternalTwoByteString::cast(src)->resource() != NULL; | 2416 return ExternalTwoByteString::cast(src)->resource() != NULL; |
| 2402 } | 2417 } |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3042 #undef WRITE_INT_FIELD | 3057 #undef WRITE_INT_FIELD |
| 3043 #undef READ_SHORT_FIELD | 3058 #undef READ_SHORT_FIELD |
| 3044 #undef WRITE_SHORT_FIELD | 3059 #undef WRITE_SHORT_FIELD |
| 3045 #undef READ_BYTE_FIELD | 3060 #undef READ_BYTE_FIELD |
| 3046 #undef WRITE_BYTE_FIELD | 3061 #undef WRITE_BYTE_FIELD |
| 3047 | 3062 |
| 3048 | 3063 |
| 3049 } } // namespace v8::internal | 3064 } } // namespace v8::internal |
| 3050 | 3065 |
| 3051 #endif // V8_OBJECTS_INL_H_ | 3066 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |