| 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 4164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4175 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; | 4175 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; |
| 4176 Object* obj; | 4176 Object* obj; |
| 4177 { MaybeObject* maybe_obj = Allocate(map, space); | 4177 { MaybeObject* maybe_obj = Allocate(map, space); |
| 4178 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4178 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 4179 } | 4179 } |
| 4180 | 4180 |
| 4181 // Initialize the JSObject. | 4181 // Initialize the JSObject. |
| 4182 InitializeJSObjectFromMap(JSObject::cast(obj), | 4182 InitializeJSObjectFromMap(JSObject::cast(obj), |
| 4183 FixedArray::cast(properties), | 4183 FixedArray::cast(properties), |
| 4184 map); | 4184 map); |
| 4185 ASSERT(JSObject::cast(obj)->HasFastSmiOrObjectElements()); | 4185 ASSERT(JSObject::cast(obj)->HasFastElements()); |
| 4186 return obj; | 4186 return obj; |
| 4187 } | 4187 } |
| 4188 | 4188 |
| 4189 | 4189 |
| 4190 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, | 4190 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, |
| 4191 PretenureFlag pretenure) { | 4191 PretenureFlag pretenure) { |
| 4192 // Allocate the initial map if absent. | 4192 // Allocate the initial map if absent. |
| 4193 if (!constructor->has_initial_map()) { | 4193 if (!constructor->has_initial_map()) { |
| 4194 Object* initial_map; | 4194 Object* initial_map; |
| 4195 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); | 4195 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4240 if (!maybe_array->To(&array)) return maybe_array; | 4240 if (!maybe_array->To(&array)) return maybe_array; |
| 4241 | 4241 |
| 4242 if (capacity == 0) { | 4242 if (capacity == 0) { |
| 4243 array->set_length(Smi::FromInt(0)); | 4243 array->set_length(Smi::FromInt(0)); |
| 4244 array->set_elements(empty_fixed_array()); | 4244 array->set_elements(empty_fixed_array()); |
| 4245 return array; | 4245 return array; |
| 4246 } | 4246 } |
| 4247 | 4247 |
| 4248 FixedArrayBase* elms; | 4248 FixedArrayBase* elms; |
| 4249 MaybeObject* maybe_elms = NULL; | 4249 MaybeObject* maybe_elms = NULL; |
| 4250 if (elements_kind == FAST_DOUBLE_ELEMENTS) { | 4250 if (IsFastDoubleElementsKind(elements_kind)) { |
| 4251 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 4251 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
| 4252 maybe_elms = AllocateUninitializedFixedDoubleArray(capacity); | 4252 maybe_elms = AllocateUninitializedFixedDoubleArray(capacity); |
| 4253 } else { | 4253 } else { |
| 4254 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 4254 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 4255 maybe_elms = AllocateFixedDoubleArrayWithHoles(capacity); | 4255 maybe_elms = AllocateFixedDoubleArrayWithHoles(capacity); |
| 4256 } | 4256 } |
| 4257 } else { | 4257 } else { |
| 4258 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); | 4258 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); |
| 4259 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 4259 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
| 4260 maybe_elms = AllocateUninitializedFixedArray(capacity); | 4260 maybe_elms = AllocateUninitializedFixedArray(capacity); |
| 4261 } else { | 4261 } else { |
| 4262 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 4262 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 4263 maybe_elms = AllocateFixedArrayWithHoles(capacity); | 4263 maybe_elms = AllocateFixedArrayWithHoles(capacity); |
| 4264 } | 4264 } |
| 4265 } | 4265 } |
| 4266 if (!maybe_elms->To(&elms)) return maybe_elms; | 4266 if (!maybe_elms->To(&elms)) return maybe_elms; |
| 4267 | 4267 |
| 4268 array->set_elements(elms); | 4268 array->set_elements(elms); |
| 4269 array->set_length(Smi::FromInt(length)); | 4269 array->set_length(Smi::FromInt(length)); |
| 4270 return array; | 4270 return array; |
| 4271 } | 4271 } |
| 4272 | 4272 |
| 4273 | 4273 |
| 4274 MaybeObject* Heap::AllocateJSArrayWithElements( | 4274 MaybeObject* Heap::AllocateJSArrayWithElements( |
| 4275 FixedArrayBase* elements, | 4275 FixedArrayBase* elements, |
| 4276 ElementsKind elements_kind, | 4276 ElementsKind elements_kind, |
| 4277 int length, |
| 4277 PretenureFlag pretenure) { | 4278 PretenureFlag pretenure) { |
| 4278 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); | 4279 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); |
| 4279 JSArray* array; | 4280 JSArray* array; |
| 4280 if (!maybe_array->To(&array)) return maybe_array; | 4281 if (!maybe_array->To(&array)) return maybe_array; |
| 4281 | 4282 |
| 4282 array->set_elements(elements); | 4283 array->set_elements(elements); |
| 4283 array->set_length(Smi::FromInt(elements->length())); | 4284 array->set_length(Smi::FromInt(length)); |
| 4284 array->ValidateElements(); | 4285 array->ValidateElements(); |
| 4285 return array; | 4286 return array; |
| 4286 } | 4287 } |
| 4287 | 4288 |
| 4288 | 4289 |
| 4289 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { | 4290 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { |
| 4290 // Allocate map. | 4291 // Allocate map. |
| 4291 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | 4292 // TODO(rossberg): Once we optimize proxies, think about a scheme to share |
| 4292 // maps. Will probably depend on the identity of the handler object, too. | 4293 // maps. Will probably depend on the identity of the handler object, too. |
| 4293 Map* map; | 4294 Map* map; |
| (...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7503 static_cast<int>(object_sizes_last_time_[index])); | 7504 static_cast<int>(object_sizes_last_time_[index])); |
| 7504 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7505 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7505 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7506 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7506 | 7507 |
| 7507 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7508 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7508 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7509 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7509 ClearObjectStats(); | 7510 ClearObjectStats(); |
| 7510 } | 7511 } |
| 7511 | 7512 |
| 7512 } } // namespace v8::internal | 7513 } } // namespace v8::internal |
| OLD | NEW |