Chromium Code Reviews| 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 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4174 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; | 4174 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; |
| 4175 Object* obj; | 4175 Object* obj; |
| 4176 { MaybeObject* maybe_obj = Allocate(map, space); | 4176 { MaybeObject* maybe_obj = Allocate(map, space); |
| 4177 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4177 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 4178 } | 4178 } |
| 4179 | 4179 |
| 4180 // Initialize the JSObject. | 4180 // Initialize the JSObject. |
| 4181 InitializeJSObjectFromMap(JSObject::cast(obj), | 4181 InitializeJSObjectFromMap(JSObject::cast(obj), |
| 4182 FixedArray::cast(properties), | 4182 FixedArray::cast(properties), |
| 4183 map); | 4183 map); |
| 4184 ASSERT(JSObject::cast(obj)->HasFastSmiOrObjectElements()); | 4184 // ASSERT(JSObject::cast(obj)->HasFastSmiOrObjectElements()); |
|
danno
2012/11/13 22:05:12
Remove //?
Toon Verwaest
2012/11/14 11:53:13
Done.
| |
| 4185 return obj; | 4185 return obj; |
| 4186 } | 4186 } |
| 4187 | 4187 |
| 4188 | 4188 |
| 4189 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, | 4189 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, |
| 4190 PretenureFlag pretenure) { | 4190 PretenureFlag pretenure) { |
| 4191 // Allocate the initial map if absent. | 4191 // Allocate the initial map if absent. |
| 4192 if (!constructor->has_initial_map()) { | 4192 if (!constructor->has_initial_map()) { |
| 4193 Object* initial_map; | 4193 Object* initial_map; |
| 4194 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); | 4194 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4239 if (!maybe_array->To(&array)) return maybe_array; | 4239 if (!maybe_array->To(&array)) return maybe_array; |
| 4240 | 4240 |
| 4241 if (capacity == 0) { | 4241 if (capacity == 0) { |
| 4242 array->set_length(Smi::FromInt(0)); | 4242 array->set_length(Smi::FromInt(0)); |
| 4243 array->set_elements(empty_fixed_array()); | 4243 array->set_elements(empty_fixed_array()); |
| 4244 return array; | 4244 return array; |
| 4245 } | 4245 } |
| 4246 | 4246 |
| 4247 FixedArrayBase* elms; | 4247 FixedArrayBase* elms; |
| 4248 MaybeObject* maybe_elms = NULL; | 4248 MaybeObject* maybe_elms = NULL; |
| 4249 if (elements_kind == FAST_DOUBLE_ELEMENTS) { | 4249 if (elements_kind == FAST_DOUBLE_ELEMENTS || |
|
danno
2012/11/13 22:05:12
IsFastDoubleElements(elements_kind)
| |
| 4250 elements_kind == FAST_HOLEY_DOUBLE_ELEMENTS) { | |
| 4250 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 4251 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
| 4251 maybe_elms = AllocateUninitializedFixedDoubleArray(capacity); | 4252 maybe_elms = AllocateUninitializedFixedDoubleArray(capacity); |
| 4252 } else { | 4253 } else { |
| 4253 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 4254 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 4254 maybe_elms = AllocateFixedDoubleArrayWithHoles(capacity); | 4255 maybe_elms = AllocateFixedDoubleArrayWithHoles(capacity); |
| 4255 } | 4256 } |
| 4256 } else { | 4257 } else { |
| 4257 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); | 4258 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); |
| 4258 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 4259 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
| 4259 maybe_elms = AllocateUninitializedFixedArray(capacity); | 4260 maybe_elms = AllocateUninitializedFixedArray(capacity); |
| 4260 } else { | 4261 } else { |
| 4261 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 4262 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 4262 maybe_elms = AllocateFixedArrayWithHoles(capacity); | 4263 maybe_elms = AllocateFixedArrayWithHoles(capacity); |
| 4263 } | 4264 } |
| 4264 } | 4265 } |
| 4265 if (!maybe_elms->To(&elms)) return maybe_elms; | 4266 if (!maybe_elms->To(&elms)) return maybe_elms; |
| 4266 | 4267 |
| 4267 array->set_elements(elms); | 4268 array->set_elements(elms); |
| 4268 array->set_length(Smi::FromInt(length)); | 4269 array->set_length(Smi::FromInt(length)); |
| 4269 return array; | 4270 return array; |
| 4270 } | 4271 } |
| 4271 | 4272 |
| 4272 | 4273 |
| 4273 MaybeObject* Heap::AllocateJSArrayWithElements( | 4274 MaybeObject* Heap::AllocateJSArrayWithElements( |
| 4274 FixedArrayBase* elements, | 4275 FixedArrayBase* elements, |
| 4275 ElementsKind elements_kind, | 4276 ElementsKind elements_kind, |
| 4277 int length, | |
| 4276 PretenureFlag pretenure) { | 4278 PretenureFlag pretenure) { |
| 4277 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); | 4279 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); |
| 4278 JSArray* array; | 4280 JSArray* array; |
| 4279 if (!maybe_array->To(&array)) return maybe_array; | 4281 if (!maybe_array->To(&array)) return maybe_array; |
| 4280 | 4282 |
| 4281 array->set_elements(elements); | 4283 array->set_elements(elements); |
| 4282 array->set_length(Smi::FromInt(elements->length())); | 4284 array->set_length(Smi::FromInt(length)); |
| 4283 array->ValidateElements(); | 4285 array->ValidateElements(); |
| 4284 return array; | 4286 return array; |
| 4285 } | 4287 } |
| 4286 | 4288 |
| 4287 | 4289 |
| 4288 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { | 4290 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { |
| 4289 // Allocate map. | 4291 // Allocate map. |
| 4290 // 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 |
| 4291 // 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. |
| 4292 Map* map; | 4294 Map* map; |
| (...skipping 3208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7501 static_cast<int>(object_sizes_last_time_[index])); | 7503 static_cast<int>(object_sizes_last_time_[index])); |
| 7502 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7504 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7503 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7505 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7504 | 7506 |
| 7505 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7507 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7506 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7508 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7507 ClearObjectStats(); | 7509 ClearObjectStats(); |
| 7508 } | 7510 } |
| 7509 | 7511 |
| 7510 } } // namespace v8::internal | 7512 } } // namespace v8::internal |
| OLD | NEW |