| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 | 2014 |
| 2015 | 2015 |
| 2016 Object* Heap::Allocate(Map* map, AllocationSpace space) { | 2016 Object* Heap::Allocate(Map* map, AllocationSpace space) { |
| 2017 ASSERT(gc_state_ == NOT_IN_GC); | 2017 ASSERT(gc_state_ == NOT_IN_GC); |
| 2018 ASSERT(map->instance_type() != MAP_TYPE); | 2018 ASSERT(map->instance_type() != MAP_TYPE); |
| 2019 Object* result = AllocateRaw(map->instance_size(), | 2019 Object* result = AllocateRaw(map->instance_size(), |
| 2020 space, | 2020 space, |
| 2021 TargetSpaceId(map->instance_type())); | 2021 TargetSpaceId(map->instance_type())); |
| 2022 if (result->IsFailure()) return result; | 2022 if (result->IsFailure()) return result; |
| 2023 HeapObject::cast(result)->set_map(map); | 2023 HeapObject::cast(result)->set_map(map); |
| 2024 ProducerHeapProfile::RecordJSObjectAllocation(result); |
| 2024 return result; | 2025 return result; |
| 2025 } | 2026 } |
| 2026 | 2027 |
| 2027 | 2028 |
| 2028 Object* Heap::InitializeFunction(JSFunction* function, | 2029 Object* Heap::InitializeFunction(JSFunction* function, |
| 2029 SharedFunctionInfo* shared, | 2030 SharedFunctionInfo* shared, |
| 2030 Object* prototype) { | 2031 Object* prototype) { |
| 2031 ASSERT(!prototype->IsMap()); | 2032 ASSERT(!prototype->IsMap()); |
| 2032 function->initialize_properties(); | 2033 function->initialize_properties(); |
| 2033 function->initialize_elements(); | 2034 function->initialize_elements(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 if (elem->IsFailure()) return elem; | 2336 if (elem->IsFailure()) return elem; |
| 2336 JSObject::cast(clone)->set_elements(FixedArray::cast(elem)); | 2337 JSObject::cast(clone)->set_elements(FixedArray::cast(elem)); |
| 2337 } | 2338 } |
| 2338 // Update properties if necessary. | 2339 // Update properties if necessary. |
| 2339 if (properties->length() > 0) { | 2340 if (properties->length() > 0) { |
| 2340 Object* prop = CopyFixedArray(properties); | 2341 Object* prop = CopyFixedArray(properties); |
| 2341 if (prop->IsFailure()) return prop; | 2342 if (prop->IsFailure()) return prop; |
| 2342 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); | 2343 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); |
| 2343 } | 2344 } |
| 2344 // Return the new clone. | 2345 // Return the new clone. |
| 2346 ProducerHeapProfile::RecordJSObjectAllocation(clone); |
| 2345 return clone; | 2347 return clone; |
| 2346 } | 2348 } |
| 2347 | 2349 |
| 2348 | 2350 |
| 2349 Object* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, | 2351 Object* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, |
| 2350 JSGlobalProxy* object) { | 2352 JSGlobalProxy* object) { |
| 2351 // Allocate initial map if absent. | 2353 // Allocate initial map if absent. |
| 2352 if (!constructor->has_initial_map()) { | 2354 if (!constructor->has_initial_map()) { |
| 2353 Object* initial_map = AllocateInitialMap(constructor); | 2355 Object* initial_map = AllocateInitialMap(constructor); |
| 2354 if (initial_map->IsFailure()) return initial_map; | 2356 if (initial_map->IsFailure()) return initial_map; |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3301 if (!CreateInitialMaps()) return false; | 3303 if (!CreateInitialMaps()) return false; |
| 3302 if (!CreateApiObjects()) return false; | 3304 if (!CreateApiObjects()) return false; |
| 3303 | 3305 |
| 3304 // Create initial objects | 3306 // Create initial objects |
| 3305 if (!CreateInitialObjects()) return false; | 3307 if (!CreateInitialObjects()) return false; |
| 3306 } | 3308 } |
| 3307 | 3309 |
| 3308 LOG(IntEvent("heap-capacity", Capacity())); | 3310 LOG(IntEvent("heap-capacity", Capacity())); |
| 3309 LOG(IntEvent("heap-available", Available())); | 3311 LOG(IntEvent("heap-available", Available())); |
| 3310 | 3312 |
| 3313 // This should be called only after initial objects have been created. |
| 3314 ProducerHeapProfile::Setup(); |
| 3315 |
| 3311 return true; | 3316 return true; |
| 3312 } | 3317 } |
| 3313 | 3318 |
| 3314 | 3319 |
| 3315 void Heap::SetStackLimit(intptr_t limit) { | 3320 void Heap::SetStackLimit(intptr_t limit) { |
| 3316 // On 64 bit machines, pointers are generally out of range of Smis. We write | 3321 // On 64 bit machines, pointers are generally out of range of Smis. We write |
| 3317 // something that looks like an out of range Smi to the GC. | 3322 // something that looks like an out of range Smi to the GC. |
| 3318 | 3323 |
| 3319 // Set up the special root array entry containing the stack guard. | 3324 // Set up the special root array entry containing the stack guard. |
| 3320 // This is actually an address, but the tag makes the GC ignore it. | 3325 // This is actually an address, but the tag makes the GC ignore it. |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 for (int i = 0; i < kNumberOfCaches; i++) { | 3892 for (int i = 0; i < kNumberOfCaches; i++) { |
| 3888 if (caches_[i] != NULL) { | 3893 if (caches_[i] != NULL) { |
| 3889 delete caches_[i]; | 3894 delete caches_[i]; |
| 3890 caches_[i] = NULL; | 3895 caches_[i] = NULL; |
| 3891 } | 3896 } |
| 3892 } | 3897 } |
| 3893 } | 3898 } |
| 3894 | 3899 |
| 3895 | 3900 |
| 3896 } } // namespace v8::internal | 3901 } } // namespace v8::internal |
| OLD | NEW |