| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 if (OLD_POINTER_SPACE == space) { | 77 if (OLD_POINTER_SPACE == space) { |
| 78 result = old_pointer_space_->AllocateRaw(size_in_bytes); | 78 result = old_pointer_space_->AllocateRaw(size_in_bytes); |
| 79 } else if (OLD_DATA_SPACE == space) { | 79 } else if (OLD_DATA_SPACE == space) { |
| 80 result = old_data_space_->AllocateRaw(size_in_bytes); | 80 result = old_data_space_->AllocateRaw(size_in_bytes); |
| 81 } else if (CODE_SPACE == space) { | 81 } else if (CODE_SPACE == space) { |
| 82 result = code_space_->AllocateRaw(size_in_bytes); | 82 result = code_space_->AllocateRaw(size_in_bytes); |
| 83 } else if (LO_SPACE == space) { | 83 } else if (LO_SPACE == space) { |
| 84 result = lo_space_->AllocateRaw(size_in_bytes); | 84 result = lo_space_->AllocateRaw(size_in_bytes); |
| 85 } else if (CELL_SPACE == space) { |
| 86 result = cell_space_->AllocateRaw(size_in_bytes); |
| 85 } else { | 87 } else { |
| 86 ASSERT(MAP_SPACE == space); | 88 ASSERT(MAP_SPACE == space); |
| 87 result = map_space_->AllocateRaw(size_in_bytes); | 89 result = map_space_->AllocateRaw(size_in_bytes); |
| 88 } | 90 } |
| 89 if (result->IsFailure()) old_gen_exhausted_ = true; | 91 if (result->IsFailure()) old_gen_exhausted_ = true; |
| 90 return result; | 92 return result; |
| 91 } | 93 } |
| 92 | 94 |
| 93 | 95 |
| 94 Object* Heap::NumberFromInt32(int32_t value) { | 96 Object* Heap::NumberFromInt32(int32_t value) { |
| 95 if (Smi::IsValid(value)) return Smi::FromInt(value); | 97 if (Smi::IsValid(value)) return Smi::FromInt(value); |
| 96 // Bypass NumberFromDouble to avoid various redundant checks. | 98 // Bypass NumberFromDouble to avoid various redundant checks. |
| 97 return AllocateHeapNumber(FastI2D(value)); | 99 return AllocateHeapNumber(FastI2D(value)); |
| 98 } | 100 } |
| 99 | 101 |
| 100 | 102 |
| 101 Object* Heap::NumberFromUint32(uint32_t value) { | 103 Object* Heap::NumberFromUint32(uint32_t value) { |
| 102 if ((int32_t)value >= 0 && Smi::IsValid((int32_t)value)) { | 104 if ((int32_t)value >= 0 && Smi::IsValid((int32_t)value)) { |
| 103 return Smi::FromInt((int32_t)value); | 105 return Smi::FromInt((int32_t)value); |
| 104 } | 106 } |
| 105 // Bypass NumberFromDouble to avoid various redundant checks. | 107 // Bypass NumberFromDouble to avoid various redundant checks. |
| 106 return AllocateHeapNumber(FastUI2D(value)); | 108 return AllocateHeapNumber(FastUI2D(value)); |
| 107 } | 109 } |
| 108 | 110 |
| 109 | 111 |
| 110 Object* Heap::AllocateRawMap(int size_in_bytes) { | 112 Object* Heap::AllocateRawMap() { |
| 111 #ifdef DEBUG | 113 #ifdef DEBUG |
| 112 Counters::objs_since_last_full.Increment(); | 114 Counters::objs_since_last_full.Increment(); |
| 113 Counters::objs_since_last_young.Increment(); | 115 Counters::objs_since_last_young.Increment(); |
| 114 #endif | 116 #endif |
| 115 Object* result = map_space_->AllocateRaw(size_in_bytes); | 117 Object* result = map_space_->AllocateRaw(Map::kSize); |
| 118 if (result->IsFailure()) old_gen_exhausted_ = true; |
| 119 return result; |
| 120 } |
| 121 |
| 122 |
| 123 Object* Heap::AllocateRawCell() { |
| 124 #ifdef DEBUG |
| 125 Counters::objs_since_last_full.Increment(); |
| 126 Counters::objs_since_last_young.Increment(); |
| 127 #endif |
| 128 Object* result = cell_space_->AllocateRaw(JSGlobalPropertyCell::kSize); |
| 116 if (result->IsFailure()) old_gen_exhausted_ = true; | 129 if (result->IsFailure()) old_gen_exhausted_ = true; |
| 117 return result; | 130 return result; |
| 118 } | 131 } |
| 119 | 132 |
| 120 | 133 |
| 121 bool Heap::InNewSpace(Object* object) { | 134 bool Heap::InNewSpace(Object* object) { |
| 122 return new_space_.Contains(object); | 135 return new_space_.Contains(object); |
| 123 } | 136 } |
| 124 | 137 |
| 125 | 138 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 allocation_allowed_ = new_state; | 294 allocation_allowed_ = new_state; |
| 282 return old; | 295 return old; |
| 283 } | 296 } |
| 284 | 297 |
| 285 #endif | 298 #endif |
| 286 | 299 |
| 287 | 300 |
| 288 } } // namespace v8::internal | 301 } } // namespace v8::internal |
| 289 | 302 |
| 290 #endif // V8_HEAP_INL_H_ | 303 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |