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

Side by Side Diff: src/objects.cc

Issue 18096: Experimental: merge from bleeding_edge. Merge up to and including... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 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
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 #include "scanner.h" 36 #include "scanner.h"
37 #include "scopeinfo.h" 37 #include "scopeinfo.h"
38 #include "string-stream.h" 38 #include "string-stream.h"
39 39
40 #ifdef ENABLE_DISASSEMBLER 40 #ifdef ENABLE_DISASSEMBLER
41 #include "disassembler.h" 41 #include "disassembler.h"
42 #endif 42 #endif
43 43
44 namespace v8 { namespace internal { 44 namespace v8 { namespace internal {
45 45
46 #define FIELD_ADDR(p, offset) \
47 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
48
49
50 #define WRITE_FIELD(p, offset, value) \
51 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
52
53
54 #define WRITE_INT_FIELD(p, offset, value) \
55 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
56
57
58 #define WRITE_BARRIER(object, offset) \
59 Heap::RecordWrite(object->address(), offset);
60
61
46 // Getters and setters are stored in a fixed array property. These are 62 // Getters and setters are stored in a fixed array property. These are
47 // constants for their indices. 63 // constants for their indices.
48 const int kGetterIndex = 0; 64 const int kGetterIndex = 0;
49 const int kSetterIndex = 1; 65 const int kSetterIndex = 1;
50 66
51 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { 67 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) {
52 // There is a constraint on the object; check 68 // There is a constraint on the object; check
53 if (!this->IsJSObject()) return false; 69 if (!this->IsJSObject()) return false;
54 // Fetch the constructor function of the object 70 // Fetch the constructor function of the object
55 Object* cons_obj = JSObject::cast(this)->map()->constructor(); 71 Object* cons_obj = JSObject::cast(this)->map()->constructor();
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 break; 933 break;
918 } 934 }
919 return; 935 return;
920 } 936 }
921 937
922 switch (type) { 938 switch (type) {
923 case FIXED_ARRAY_TYPE: 939 case FIXED_ARRAY_TYPE:
924 reinterpret_cast<FixedArray*>(this)->FixedArrayIterateBody(v); 940 reinterpret_cast<FixedArray*>(this)->FixedArrayIterateBody(v);
925 break; 941 break;
926 case JS_OBJECT_TYPE: 942 case JS_OBJECT_TYPE:
943 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
927 case JS_VALUE_TYPE: 944 case JS_VALUE_TYPE:
928 case JS_ARRAY_TYPE: 945 case JS_ARRAY_TYPE:
929 case JS_REGEXP_TYPE: 946 case JS_REGEXP_TYPE:
930 case JS_FUNCTION_TYPE: 947 case JS_FUNCTION_TYPE:
931 case JS_GLOBAL_PROXY_TYPE: 948 case JS_GLOBAL_PROXY_TYPE:
932 case JS_GLOBAL_OBJECT_TYPE: 949 case JS_GLOBAL_OBJECT_TYPE:
933 case JS_BUILTINS_OBJECT_TYPE: 950 case JS_BUILTINS_OBJECT_TYPE:
934 reinterpret_cast<JSObject*>(this)->JSObjectIterateBody(object_size, v); 951 reinterpret_cast<JSObject*>(this)->JSObjectIterateBody(object_size, v);
935 break; 952 break;
936 case ODDBALL_TYPE: 953 case ODDBALL_TYPE:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 return FastPropertyAtPut(index, value); 1050 return FastPropertyAtPut(index, value);
1034 } 1051 }
1035 1052
1036 1053
1037 Object* JSObject::AddFastProperty(String* name, 1054 Object* JSObject::AddFastProperty(String* name,
1038 Object* value, 1055 Object* value,
1039 PropertyAttributes attributes) { 1056 PropertyAttributes attributes) {
1040 // Normalize the object if the name is not a real identifier. 1057 // Normalize the object if the name is not a real identifier.
1041 StringInputBuffer buffer(name); 1058 StringInputBuffer buffer(name);
1042 if (!Scanner::IsIdentifier(&buffer)) { 1059 if (!Scanner::IsIdentifier(&buffer)) {
1043 Object* obj = NormalizeProperties(); 1060 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1044 if (obj->IsFailure()) return obj; 1061 if (obj->IsFailure()) return obj;
1045 return AddSlowProperty(name, value, attributes); 1062 return AddSlowProperty(name, value, attributes);
1046 } 1063 }
1047 1064
1048 DescriptorArray* old_descriptors = map()->instance_descriptors(); 1065 DescriptorArray* old_descriptors = map()->instance_descriptors();
1049 // Compute the new index for new field. 1066 // Compute the new index for new field.
1050 int index = map()->NextFreePropertyIndex(); 1067 int index = map()->NextFreePropertyIndex();
1051 1068
1052 // Allocate new instance descriptors with (name, index) added 1069 // Allocate new instance descriptors with (name, index) added
1053 FieldDescriptor new_field(name, index, attributes); 1070 FieldDescriptor new_field(name, index, attributes);
(...skipping 17 matching lines...) Expand all
1071 if (allow_map_transition) { 1088 if (allow_map_transition) {
1072 // Allocate new instance descriptors for the old map with map transition. 1089 // Allocate new instance descriptors for the old map with map transition.
1073 MapTransitionDescriptor d(name, Map::cast(new_map), attributes); 1090 MapTransitionDescriptor d(name, Map::cast(new_map), attributes);
1074 Object* r = old_descriptors->CopyInsert(&d, KEEP_TRANSITIONS); 1091 Object* r = old_descriptors->CopyInsert(&d, KEEP_TRANSITIONS);
1075 if (r->IsFailure()) return r; 1092 if (r->IsFailure()) return r;
1076 old_descriptors = DescriptorArray::cast(r); 1093 old_descriptors = DescriptorArray::cast(r);
1077 } 1094 }
1078 1095
1079 if (map()->unused_property_fields() == 0) { 1096 if (map()->unused_property_fields() == 0) {
1080 if (properties()->length() > kMaxFastProperties) { 1097 if (properties()->length() > kMaxFastProperties) {
1081 Object* obj = NormalizeProperties(); 1098 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1082 if (obj->IsFailure()) return obj; 1099 if (obj->IsFailure()) return obj;
1083 return AddSlowProperty(name, value, attributes); 1100 return AddSlowProperty(name, value, attributes);
1084 } 1101 }
1085 // Make room for the new value 1102 // Make room for the new value
1086 Object* values = 1103 Object* values =
1087 properties()->CopySize(properties()->length() + kFieldsAdded); 1104 properties()->CopySize(properties()->length() + kFieldsAdded);
1088 if (values->IsFailure()) return values; 1105 if (values->IsFailure()) return values;
1089 set_properties(FixedArray::cast(values)); 1106 set_properties(FixedArray::cast(values));
1090 new_map->set_unused_property_fields(kFieldsAdded - 1); 1107 new_map->set_unused_property_fields(kFieldsAdded - 1);
1091 } else { 1108 } else {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 if (value->IsJSFunction()) { 1190 if (value->IsJSFunction()) {
1174 return AddConstantFunctionProperty(name, 1191 return AddConstantFunctionProperty(name,
1175 JSFunction::cast(value), 1192 JSFunction::cast(value),
1176 attributes); 1193 attributes);
1177 } else { 1194 } else {
1178 return AddFastProperty(name, value, attributes); 1195 return AddFastProperty(name, value, attributes);
1179 } 1196 }
1180 } else { 1197 } else {
1181 // Normalize the object to prevent very large instance descriptors. 1198 // Normalize the object to prevent very large instance descriptors.
1182 // This eliminates unwanted N^2 allocation and lookup behavior. 1199 // This eliminates unwanted N^2 allocation and lookup behavior.
1183 Object* obj = NormalizeProperties(); 1200 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1184 if (obj->IsFailure()) return obj; 1201 if (obj->IsFailure()) return obj;
1185 } 1202 }
1186 } 1203 }
1187 return AddSlowProperty(name, value, attributes); 1204 return AddSlowProperty(name, value, attributes);
1188 } 1205 }
1189 1206
1190 1207
1191 Object* JSObject::SetPropertyPostInterceptor(String* name, 1208 Object* JSObject::SetPropertyPostInterceptor(String* name,
1192 Object* value, 1209 Object* value,
1193 PropertyAttributes attributes) { 1210 PropertyAttributes attributes) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 old_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); 1263 old_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors));
1247 return result; 1264 return result;
1248 } 1265 }
1249 1266
1250 1267
1251 Object* JSObject::ConvertDescriptorToField(String* name, 1268 Object* JSObject::ConvertDescriptorToField(String* name,
1252 Object* new_value, 1269 Object* new_value,
1253 PropertyAttributes attributes) { 1270 PropertyAttributes attributes) {
1254 if (map()->unused_property_fields() == 0 && 1271 if (map()->unused_property_fields() == 0 &&
1255 properties()->length() > kMaxFastProperties) { 1272 properties()->length() > kMaxFastProperties) {
1256 Object* obj = NormalizeProperties(); 1273 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1257 if (obj->IsFailure()) return obj; 1274 if (obj->IsFailure()) return obj;
1258 return ReplaceSlowProperty(name, new_value, attributes); 1275 return ReplaceSlowProperty(name, new_value, attributes);
1259 } 1276 }
1260 1277
1261 int index = map()->NextFreePropertyIndex(); 1278 int index = map()->NextFreePropertyIndex();
1262 FieldDescriptor new_field(name, index, attributes); 1279 FieldDescriptor new_field(name, index, attributes);
1263 // Make a new DescriptorArray replacing an entry with FieldDescriptor. 1280 // Make a new DescriptorArray replacing an entry with FieldDescriptor.
1264 Object* descriptors_unchecked = map()->instance_descriptors()-> 1281 Object* descriptors_unchecked = map()->instance_descriptors()->
1265 CopyInsert(&new_field, REMOVE_TRANSITIONS); 1282 CopyInsert(&new_field, REMOVE_TRANSITIONS);
1266 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked; 1283 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 return SetPropertyWithFailedAccessCheck(result, name, value); 1592 return SetPropertyWithFailedAccessCheck(result, name, value);
1576 } 1593 }
1577 1594
1578 if (IsJSGlobalProxy()) { 1595 if (IsJSGlobalProxy()) {
1579 Object* proto = GetPrototype(); 1596 Object* proto = GetPrototype();
1580 if (proto->IsNull()) return value; 1597 if (proto->IsNull()) return value;
1581 ASSERT(proto->IsJSGlobalObject()); 1598 ASSERT(proto->IsJSGlobalObject());
1582 return JSObject::cast(proto)->SetProperty(result, name, value, attributes); 1599 return JSObject::cast(proto)->SetProperty(result, name, value, attributes);
1583 } 1600 }
1584 1601
1585 if (result->IsNotFound() || !result->IsProperty()) { 1602 if (!result->IsProperty() && !IsJSContextExtensionObject()) {
1586 // We could not find a local property so let's check whether there is an 1603 // We could not find a local property so let's check whether there is an
1587 // accessor that wants to handle the property. 1604 // accessor that wants to handle the property.
1588 LookupResult accessor_result; 1605 LookupResult accessor_result;
1589 LookupCallbackSetterInPrototypes(name, &accessor_result); 1606 LookupCallbackSetterInPrototypes(name, &accessor_result);
1590 if (accessor_result.IsValid()) { 1607 if (accessor_result.IsValid()) {
1591 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), 1608 return SetPropertyWithCallback(accessor_result.GetCallbackObject(),
1592 name, 1609 name,
1593 value, 1610 value,
1594 accessor_result.holder()); 1611 accessor_result.holder());
1595 } 1612 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 if (HasLocalElement(index)) return NONE; 1858 if (HasLocalElement(index)) return NONE;
1842 return ABSENT; 1859 return ABSENT;
1843 } 1860 }
1844 // Named property. 1861 // Named property.
1845 LookupResult result; 1862 LookupResult result;
1846 LocalLookup(name, &result); 1863 LocalLookup(name, &result);
1847 return GetPropertyAttribute(this, &result, name, false); 1864 return GetPropertyAttribute(this, &result, name, false);
1848 } 1865 }
1849 1866
1850 1867
1851 Object* JSObject::NormalizeProperties() { 1868 Object* JSObject::NormalizeProperties(PropertyNormalizationMode mode) {
1852 if (!HasFastProperties()) return this; 1869 if (!HasFastProperties()) return this;
1853 1870
1854 // Allocate new content 1871 // Allocate new content
1855 Object* obj = 1872 Object* obj =
1856 Dictionary::Allocate(map()->NumberOfDescribedProperties() * 2 + 4); 1873 Dictionary::Allocate(map()->NumberOfDescribedProperties() * 2 + 4);
1857 if (obj->IsFailure()) return obj; 1874 if (obj->IsFailure()) return obj;
1858 Dictionary* dictionary = Dictionary::cast(obj); 1875 Dictionary* dictionary = Dictionary::cast(obj);
1859 1876
1860 for (DescriptorReader r(map()->instance_descriptors()); 1877 for (DescriptorReader r(map()->instance_descriptors());
1861 !r.eos(); 1878 !r.eos();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 } 1918 }
1902 } 1919 }
1903 1920
1904 // Copy the next enumeration index from instance descriptor. 1921 // Copy the next enumeration index from instance descriptor.
1905 int index = map()->instance_descriptors()->NextEnumerationIndex(); 1922 int index = map()->instance_descriptors()->NextEnumerationIndex();
1906 dictionary->SetNextEnumerationIndex(index); 1923 dictionary->SetNextEnumerationIndex(index);
1907 1924
1908 // Allocate new map. 1925 // Allocate new map.
1909 obj = map()->Copy(); 1926 obj = map()->Copy();
1910 if (obj->IsFailure()) return obj; 1927 if (obj->IsFailure()) return obj;
1928 Map* new_map = Map::cast(obj);
1929
1930 // Clear inobject properties if needed by adjusting the instance
1931 // size and putting in a filler or byte array instead of the
1932 // inobject properties.
1933 if (mode == CLEAR_INOBJECT_PROPERTIES && map()->inobject_properties() > 0) {
1934 int instance_size_delta = map()->inobject_properties() * kPointerSize;
1935 int new_instance_size = map()->instance_size() - instance_size_delta;
1936 new_map->set_inobject_properties(0);
1937 new_map->set_instance_size(new_instance_size);
1938 if (instance_size_delta == kPointerSize) {
1939 WRITE_FIELD(this, new_instance_size, Heap::one_word_filler_map());
1940 } else {
1941 int byte_array_length = ByteArray::LengthFor(instance_size_delta);
1942 int byte_array_length_offset = new_instance_size + kPointerSize;
1943 WRITE_FIELD(this, new_instance_size, Heap::byte_array_map());
1944 WRITE_INT_FIELD(this, byte_array_length_offset, byte_array_length);
1945 }
1946 WRITE_BARRIER(this, new_instance_size);
1947 }
1948 new_map->set_unused_property_fields(0);
1911 1949
1912 // We have now sucessfully allocated all the necessary objects. 1950 // We have now sucessfully allocated all the necessary objects.
1913 // Changes can now be made with the guarantee that all of them take effect. 1951 // Changes can now be made with the guarantee that all of them take effect.
1914 set_map(Map::cast(obj)); 1952 set_map(new_map);
1915 map()->set_instance_descriptors(Heap::empty_descriptor_array()); 1953 map()->set_instance_descriptors(Heap::empty_descriptor_array());
1916 1954
1917 map()->set_unused_property_fields(0);
1918 set_properties(dictionary); 1955 set_properties(dictionary);
1919 1956
1920 Counters::props_to_dictionary.Increment(); 1957 Counters::props_to_dictionary.Increment();
1921 1958
1922 #ifdef DEBUG 1959 #ifdef DEBUG
1923 if (FLAG_trace_normalization) { 1960 if (FLAG_trace_normalization) {
1924 PrintF("Object properties have been normalized:\n"); 1961 PrintF("Object properties have been normalized:\n");
1925 Print(); 1962 Print();
1926 } 1963 }
1927 #endif 1964 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 } 2012 }
1976 2013
1977 2014
1978 Object* JSObject::DeletePropertyPostInterceptor(String* name) { 2015 Object* JSObject::DeletePropertyPostInterceptor(String* name) {
1979 // Check local property, ignore interceptor. 2016 // Check local property, ignore interceptor.
1980 LookupResult result; 2017 LookupResult result;
1981 LocalLookupRealNamedProperty(name, &result); 2018 LocalLookupRealNamedProperty(name, &result);
1982 if (!result.IsValid()) return Heap::true_value(); 2019 if (!result.IsValid()) return Heap::true_value();
1983 2020
1984 // Normalize object if needed. 2021 // Normalize object if needed.
1985 Object* obj = NormalizeProperties(); 2022 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1986 if (obj->IsFailure()) return obj; 2023 if (obj->IsFailure()) return obj;
1987 2024
1988 ASSERT(!HasFastProperties()); 2025 ASSERT(!HasFastProperties());
1989 // Attempt to remove the property from the property dictionary. 2026 // Attempt to remove the property from the property dictionary.
1990 Dictionary* dictionary = property_dictionary(); 2027 Dictionary* dictionary = property_dictionary();
1991 int entry = dictionary->FindStringEntry(name); 2028 int entry = dictionary->FindStringEntry(name);
1992 if (entry != -1) return dictionary->DeleteProperty(entry); 2029 if (entry != -1) return dictionary->DeleteProperty(entry);
1993 return Heap::true_value(); 2030 return Heap::true_value();
1994 } 2031 }
1995 2032
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 if (!result.IsValid()) return Heap::true_value(); 2175 if (!result.IsValid()) return Heap::true_value();
2139 if (result.IsDontDelete()) return Heap::false_value(); 2176 if (result.IsDontDelete()) return Heap::false_value();
2140 // Check for interceptor. 2177 // Check for interceptor.
2141 if (result.type() == INTERCEPTOR) { 2178 if (result.type() == INTERCEPTOR) {
2142 return DeletePropertyWithInterceptor(name); 2179 return DeletePropertyWithInterceptor(name);
2143 } 2180 }
2144 if (!result.IsLoaded()) { 2181 if (!result.IsLoaded()) {
2145 return JSObject::cast(this)->DeleteLazyProperty(&result, name); 2182 return JSObject::cast(this)->DeleteLazyProperty(&result, name);
2146 } 2183 }
2147 // Normalize object if needed. 2184 // Normalize object if needed.
2148 Object* obj = NormalizeProperties(); 2185 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
2149 if (obj->IsFailure()) return obj; 2186 if (obj->IsFailure()) return obj;
2150 // Make sure the properties are normalized before removing the entry. 2187 // Make sure the properties are normalized before removing the entry.
2151 Dictionary* dictionary = property_dictionary(); 2188 Dictionary* dictionary = property_dictionary();
2152 int entry = dictionary->FindStringEntry(name); 2189 int entry = dictionary->FindStringEntry(name);
2153 if (entry != -1) return dictionary->DeleteProperty(entry); 2190 if (entry != -1) return dictionary->DeleteProperty(entry);
2154 return Heap::true_value(); 2191 return Heap::true_value();
2155 } 2192 }
2156 } 2193 }
2157 2194
2158 2195
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 return JSObject::cast(proto)->LocalLookup(name, result); 2354 return JSObject::cast(proto)->LocalLookup(name, result);
2318 } 2355 }
2319 2356
2320 // Do not use inline caching if the object is a non-global object 2357 // Do not use inline caching if the object is a non-global object
2321 // that requires access checks. 2358 // that requires access checks.
2322 if (!IsJSGlobalProxy() && IsAccessCheckNeeded()) { 2359 if (!IsJSGlobalProxy() && IsAccessCheckNeeded()) {
2323 result->DisallowCaching(); 2360 result->DisallowCaching();
2324 } 2361 }
2325 2362
2326 // Check __proto__ before interceptor. 2363 // Check __proto__ before interceptor.
2327 if (name->Equals(Heap::Proto_symbol())) { 2364 if (name->Equals(Heap::Proto_symbol()) && !IsJSContextExtensionObject()) {
2328 result->ConstantResult(this); 2365 result->ConstantResult(this);
2329 return; 2366 return;
2330 } 2367 }
2331 2368
2332 // Check for lookup interceptor except when bootstrapping. 2369 // Check for lookup interceptor except when bootstrapping.
2333 if (HasNamedInterceptor() && !Bootstrapper::IsActive()) { 2370 if (HasNamedInterceptor() && !Bootstrapper::IsActive()) {
2334 result->InterceptorResult(this); 2371 result->InterceptorResult(this);
2335 return; 2372 return;
2336 } 2373 }
2337 2374
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 LocalLookup(name, &result); 2441 LocalLookup(name, &result);
2405 if (result.IsValid()) { 2442 if (result.IsValid()) {
2406 if (result.IsReadOnly()) return Heap::undefined_value(); 2443 if (result.IsReadOnly()) return Heap::undefined_value();
2407 if (result.type() == CALLBACKS) { 2444 if (result.type() == CALLBACKS) {
2408 Object* obj = result.GetCallbackObject(); 2445 Object* obj = result.GetCallbackObject();
2409 if (obj->IsFixedArray()) return obj; 2446 if (obj->IsFixedArray()) return obj;
2410 } 2447 }
2411 } 2448 }
2412 2449
2413 // Normalize object to make this operation simple. 2450 // Normalize object to make this operation simple.
2414 Object* ok = NormalizeProperties(); 2451 Object* ok = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
2415 if (ok->IsFailure()) return ok; 2452 if (ok->IsFailure()) return ok;
2416 2453
2417 // Allocate the fixed array to hold getter and setter. 2454 // Allocate the fixed array to hold getter and setter.
2418 Object* array = Heap::AllocateFixedArray(2); 2455 Object* array = Heap::AllocateFixedArray(2);
2419 if (array->IsFailure()) return array; 2456 if (array->IsFailure()) return array;
2420 2457
2421 // Update the dictionary with the new CALLBACKS property. 2458 // Update the dictionary with the new CALLBACKS property.
2422 PropertyDetails details = PropertyDetails(attributes, CALLBACKS); 2459 PropertyDetails details = PropertyDetails(attributes, CALLBACKS);
2423 Object* dict = 2460 Object* dict =
2424 property_dictionary()->SetOrAddStringEntry(name, array, details); 2461 property_dictionary()->SetOrAddStringEntry(name, array, details);
(...skipping 4232 matching lines...) Expand 10 before | Expand all | Expand 10 after
6657 if (type == NORMAL && !value->IsJSFunction()) number_of_fields += 1; 6694 if (type == NORMAL && !value->IsJSFunction()) number_of_fields += 1;
6658 } 6695 }
6659 } 6696 }
6660 6697
6661 // Allocate the instance descriptor. 6698 // Allocate the instance descriptor.
6662 Object* descriptors_unchecked = 6699 Object* descriptors_unchecked =
6663 DescriptorArray::Allocate(instance_descriptor_length); 6700 DescriptorArray::Allocate(instance_descriptor_length);
6664 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked; 6701 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked;
6665 DescriptorArray* descriptors = DescriptorArray::cast(descriptors_unchecked); 6702 DescriptorArray* descriptors = DescriptorArray::cast(descriptors_unchecked);
6666 6703
6667 int number_of_allocated_fields = number_of_fields + unused_property_fields; 6704 int inobject_props = obj->map()->inobject_properties();
6705 int number_of_allocated_fields =
6706 number_of_fields + unused_property_fields - inobject_props;
6668 6707
6669 // Allocate the fixed array for the fields. 6708 // Allocate the fixed array for the fields.
6670 Object* fields = Heap::AllocateFixedArray(number_of_allocated_fields); 6709 Object* fields = Heap::AllocateFixedArray(number_of_allocated_fields);
6671 if (fields->IsFailure()) return fields; 6710 if (fields->IsFailure()) return fields;
6672 6711
6673 // Fill in the instance descriptor and the fields. 6712 // Fill in the instance descriptor and the fields.
6674 DescriptorWriter w(descriptors); 6713 DescriptorWriter w(descriptors);
6675 int current_offset = 0; 6714 int current_offset = 0;
6676 for (int i = 0; i < capacity; i++) { 6715 for (int i = 0; i < capacity; i++) {
6677 Object* k = KeyAt(i); 6716 Object* k = KeyAt(i);
6678 if (IsKey(k)) { 6717 if (IsKey(k)) {
6679 Object* value = ValueAt(i); 6718 Object* value = ValueAt(i);
6680 // Ensure the key is a symbol before writing into the instance descriptor. 6719 // Ensure the key is a symbol before writing into the instance descriptor.
6681 Object* key = Heap::LookupSymbol(String::cast(k)); 6720 Object* key = Heap::LookupSymbol(String::cast(k));
6682 if (key->IsFailure()) return key; 6721 if (key->IsFailure()) return key;
6683 PropertyDetails details = DetailsAt(i); 6722 PropertyDetails details = DetailsAt(i);
6684 PropertyType type = details.type(); 6723 PropertyType type = details.type();
6724
6685 if (value->IsJSFunction()) { 6725 if (value->IsJSFunction()) {
6686 ConstantFunctionDescriptor d(String::cast(key), 6726 ConstantFunctionDescriptor d(String::cast(key),
6687 JSFunction::cast(value), 6727 JSFunction::cast(value),
6688 details.attributes(), 6728 details.attributes(),
6689 details.index()); 6729 details.index());
6690 w.Write(&d); 6730 w.Write(&d);
6691 } else if (type == NORMAL) { 6731 } else if (type == NORMAL) {
6692 FixedArray::cast(fields)->set(current_offset, value); 6732 if (current_offset < inobject_props) {
6733 obj->InObjectPropertyAtPut(current_offset,
6734 value,
6735 UPDATE_WRITE_BARRIER);
6736 } else {
6737 int offset = current_offset - inobject_props;
6738 FixedArray::cast(fields)->set(offset, value);
6739 }
6693 FieldDescriptor d(String::cast(key), 6740 FieldDescriptor d(String::cast(key),
6694 current_offset++, 6741 current_offset++,
6695 details.attributes(), 6742 details.attributes(),
6696 details.index()); 6743 details.index());
6697 w.Write(&d); 6744 w.Write(&d);
6698 } else if (type == CALLBACKS) { 6745 } else if (type == CALLBACKS) {
6699 CallbacksDescriptor d(String::cast(key), 6746 CallbacksDescriptor d(String::cast(key),
6700 value, 6747 value,
6701 details.attributes(), 6748 details.attributes(),
6702 details.index()); 6749 details.index());
(...skipping 12 matching lines...) Expand all
6715 6762
6716 // Transform the object. 6763 // Transform the object.
6717 obj->set_map(Map::cast(new_map)); 6764 obj->set_map(Map::cast(new_map));
6718 obj->map()->set_instance_descriptors(descriptors); 6765 obj->map()->set_instance_descriptors(descriptors);
6719 obj->map()->set_unused_property_fields(unused_property_fields); 6766 obj->map()->set_unused_property_fields(unused_property_fields);
6720 6767
6721 obj->set_properties(FixedArray::cast(fields)); 6768 obj->set_properties(FixedArray::cast(fields));
6722 ASSERT(obj->IsJSObject()); 6769 ASSERT(obj->IsJSObject());
6723 6770
6724 descriptors->SetNextEnumerationIndex(NextEnumerationIndex()); 6771 descriptors->SetNextEnumerationIndex(NextEnumerationIndex());
6725 // Check it really works. 6772 // Check that it really works.
6726 ASSERT(obj->HasFastProperties()); 6773 ASSERT(obj->HasFastProperties());
6774
6727 return obj; 6775 return obj;
6728 } 6776 }
6729 6777
6730 6778
6731 // Check if there is a break point at this code position. 6779 // Check if there is a break point at this code position.
6732 bool DebugInfo::HasBreakPoint(int code_position) { 6780 bool DebugInfo::HasBreakPoint(int code_position) {
6733 // Get the break point info object for this code position. 6781 // Get the break point info object for this code position.
6734 Object* break_point_info = GetBreakPointInfo(code_position); 6782 Object* break_point_info = GetBreakPointInfo(code_position);
6735 6783
6736 // If there is no break point info object or no break points in the break 6784 // If there is no break point info object or no break points in the break
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
6967 // No break point. 7015 // No break point.
6968 if (break_point_objects()->IsUndefined()) return 0; 7016 if (break_point_objects()->IsUndefined()) return 0;
6969 // Single beak point. 7017 // Single beak point.
6970 if (!break_point_objects()->IsFixedArray()) return 1; 7018 if (!break_point_objects()->IsFixedArray()) return 1;
6971 // Multiple break points. 7019 // Multiple break points.
6972 return FixedArray::cast(break_point_objects())->length(); 7020 return FixedArray::cast(break_point_objects())->length();
6973 } 7021 }
6974 7022
6975 7023
6976 } } // namespace v8::internal 7024 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698