| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) | 513 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) |
| 514 TYPE_CHECKER(JSSet, JS_SET_TYPE) | 514 TYPE_CHECKER(JSSet, JS_SET_TYPE) |
| 515 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 515 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
| 516 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 516 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
| 517 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 517 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
| 518 TYPE_CHECKER(Map, MAP_TYPE) | 518 TYPE_CHECKER(Map, MAP_TYPE) |
| 519 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 519 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
| 520 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 520 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
| 521 | 521 |
| 522 | 522 |
| 523 bool Object::IsHiddenPropertiesArray() { |
| 524 return IsFixedArray(); |
| 525 } |
| 526 |
| 527 |
| 523 bool Object::IsDescriptorArray() { | 528 bool Object::IsDescriptorArray() { |
| 524 return IsFixedArray(); | 529 return IsFixedArray(); |
| 525 } | 530 } |
| 526 | 531 |
| 527 | 532 |
| 528 bool Object::IsTransitionArray() { | 533 bool Object::IsTransitionArray() { |
| 529 return IsFixedArray(); | 534 return IsFixedArray(); |
| 530 } | 535 } |
| 531 | 536 |
| 532 | 537 |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 ASSERT(!heap->InNewSpace(heap->null_value())); | 1877 ASSERT(!heap->InNewSpace(heap->null_value())); |
| 1873 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); | 1878 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); |
| 1874 } | 1879 } |
| 1875 | 1880 |
| 1876 | 1881 |
| 1877 Object** FixedArray::data_start() { | 1882 Object** FixedArray::data_start() { |
| 1878 return HeapObject::RawField(this, kHeaderSize); | 1883 return HeapObject::RawField(this, kHeaderSize); |
| 1879 } | 1884 } |
| 1880 | 1885 |
| 1881 | 1886 |
| 1887 MaybeObject* HiddenPropertiesArray::Allocate() { |
| 1888 static const int initial_size = 2; |
| 1889 ASSERT(IS_POWER_OF_TWO(initial_size)); |
| 1890 return Isolate::Current()->heap()->AllocateFixedArrayWithHoles(initial_size); |
| 1891 } |
| 1892 |
| 1893 |
| 1894 MaybeObject* HiddenPropertiesArray::Set(String* key, Object* value) { |
| 1895 for (int i = 0; i < length(); i += 2) { |
| 1896 if (is_the_hole(i) || String::cast(get(i))->Equals(key)) { |
| 1897 set(i, key); |
| 1898 set(i + 1, value); |
| 1899 return this; |
| 1900 } |
| 1901 } |
| 1902 // Need to extend the backing store. |
| 1903 int old_size = length(); |
| 1904 int new_size = old_size << 1; |
| 1905 ASSERT(IS_POWER_OF_TWO(new_size)); |
| 1906 FixedArray* new_array; |
| 1907 { MaybeObject* maybe_obj = GetHeap()->AllocateFixedArrayWithHoles(new_size); |
| 1908 if (!maybe_obj->To<FixedArray>(&new_array)) return maybe_obj; |
| 1909 } |
| 1910 CopyTo(0, new_array, 0, old_size); |
| 1911 new_array->set(old_size, key); |
| 1912 new_array->set(old_size + 1, value); |
| 1913 return new_array; |
| 1914 } |
| 1915 |
| 1916 |
| 1917 void HiddenPropertiesArray::Delete(String* key) { |
| 1918 // Linear search to find the key and delete the entry. |
| 1919 for (int i = 0; i < length(); i += 2) { |
| 1920 if (is_the_hole(i)) { |
| 1921 if (is_the_hole(i + 1)) { |
| 1922 // Both key and value are holes. This is the end of the list. |
| 1923 return; |
| 1924 } |
| 1925 } else if (String::cast(get(i))->Equals(key)) { |
| 1926 // Set the value field to undefined (not the hole) to signal that the |
| 1927 // list may not end here. |
| 1928 set_the_hole(i); |
| 1929 set_undefined(i + 1); |
| 1930 return; |
| 1931 } |
| 1932 } |
| 1933 } |
| 1934 |
| 1935 |
| 1936 Object* HiddenPropertiesArray::Get(String* key) { |
| 1937 // Linear search to find the key and return the value. |
| 1938 for (int i = 0; i < length(); i += 2) { |
| 1939 if (is_the_hole(i)) { |
| 1940 if (is_the_hole(i + 1)) { |
| 1941 // Both key and value are holes. This is the end of the list. |
| 1942 break; |
| 1943 } |
| 1944 } else if (String::cast(get(i))->Equals(key)) { |
| 1945 return get(i + 1); |
| 1946 } |
| 1947 } |
| 1948 // Not found, return undefined. |
| 1949 return GetHeap()->undefined_value(); |
| 1950 } |
| 1951 |
| 1952 |
| 1882 bool DescriptorArray::IsEmpty() { | 1953 bool DescriptorArray::IsEmpty() { |
| 1883 ASSERT(length() >= kFirstIndex || | 1954 ASSERT(length() >= kFirstIndex || |
| 1884 this == HEAP->empty_descriptor_array()); | 1955 this == HEAP->empty_descriptor_array()); |
| 1885 return length() < kFirstIndex; | 1956 return length() < kFirstIndex; |
| 1886 } | 1957 } |
| 1887 | 1958 |
| 1888 | 1959 |
| 1889 bool DescriptorArray::MayContainTransitions() { | 1960 bool DescriptorArray::MayContainTransitions() { |
| 1890 return !IsEmpty(); | 1961 return !IsEmpty(); |
| 1891 } | 1962 } |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2283 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 2213 } | 2284 } |
| 2214 | 2285 |
| 2215 | 2286 |
| 2216 // ------------------------------------ | 2287 // ------------------------------------ |
| 2217 // Cast operations | 2288 // Cast operations |
| 2218 | 2289 |
| 2219 | 2290 |
| 2220 CAST_ACCESSOR(FixedArray) | 2291 CAST_ACCESSOR(FixedArray) |
| 2221 CAST_ACCESSOR(FixedDoubleArray) | 2292 CAST_ACCESSOR(FixedDoubleArray) |
| 2293 CAST_ACCESSOR(HiddenPropertiesArray) |
| 2222 CAST_ACCESSOR(DescriptorArray) | 2294 CAST_ACCESSOR(DescriptorArray) |
| 2223 CAST_ACCESSOR(DeoptimizationInputData) | 2295 CAST_ACCESSOR(DeoptimizationInputData) |
| 2224 CAST_ACCESSOR(DeoptimizationOutputData) | 2296 CAST_ACCESSOR(DeoptimizationOutputData) |
| 2225 CAST_ACCESSOR(TypeFeedbackCells) | 2297 CAST_ACCESSOR(TypeFeedbackCells) |
| 2226 CAST_ACCESSOR(SymbolTable) | 2298 CAST_ACCESSOR(SymbolTable) |
| 2227 CAST_ACCESSOR(JSFunctionResultCache) | 2299 CAST_ACCESSOR(JSFunctionResultCache) |
| 2228 CAST_ACCESSOR(NormalizedMapCache) | 2300 CAST_ACCESSOR(NormalizedMapCache) |
| 2229 CAST_ACCESSOR(ScopeInfo) | 2301 CAST_ACCESSOR(ScopeInfo) |
| 2230 CAST_ACCESSOR(CompilationCacheTable) | 2302 CAST_ACCESSOR(CompilationCacheTable) |
| 2231 CAST_ACCESSOR(CodeCacheHashTable) | 2303 CAST_ACCESSOR(CodeCacheHashTable) |
| (...skipping 3158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5390 #undef WRITE_UINT32_FIELD | 5462 #undef WRITE_UINT32_FIELD |
| 5391 #undef READ_SHORT_FIELD | 5463 #undef READ_SHORT_FIELD |
| 5392 #undef WRITE_SHORT_FIELD | 5464 #undef WRITE_SHORT_FIELD |
| 5393 #undef READ_BYTE_FIELD | 5465 #undef READ_BYTE_FIELD |
| 5394 #undef WRITE_BYTE_FIELD | 5466 #undef WRITE_BYTE_FIELD |
| 5395 | 5467 |
| 5396 | 5468 |
| 5397 } } // namespace v8::internal | 5469 } } // namespace v8::internal |
| 5398 | 5470 |
| 5399 #endif // V8_OBJECTS_INL_H_ | 5471 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |