OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 | 1806 |
1807 MaybeObject* Heap::AllocateMap(InstanceType instance_type, | 1807 MaybeObject* Heap::AllocateMap(InstanceType instance_type, |
1808 int instance_size, | 1808 int instance_size, |
1809 ElementsKind elements_kind) { | 1809 ElementsKind elements_kind) { |
1810 Object* result; | 1810 Object* result; |
1811 { MaybeObject* maybe_result = AllocateRawMap(); | 1811 { MaybeObject* maybe_result = AllocateRawMap(); |
1812 if (!maybe_result->ToObject(&result)) return maybe_result; | 1812 if (!maybe_result->ToObject(&result)) return maybe_result; |
1813 } | 1813 } |
1814 | 1814 |
1815 Map* map = reinterpret_cast<Map*>(result); | 1815 Map* map = reinterpret_cast<Map*>(result); |
1816 map->set_map_unsafe(meta_map()); | 1816 map->set_map_no_wb(meta_map()); |
1817 map->set_instance_type(instance_type); | 1817 map->set_instance_type(instance_type); |
1818 map->set_visitor_id( | 1818 map->set_visitor_id( |
1819 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 1819 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); |
1820 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); | 1820 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); |
1821 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); | 1821 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); |
1822 map->set_instance_size(instance_size); | 1822 map->set_instance_size(instance_size); |
1823 map->set_inobject_properties(0); | 1823 map->set_inobject_properties(0); |
1824 map->set_pre_allocated_property_fields(0); | 1824 map->set_pre_allocated_property_fields(0); |
1825 map->init_instance_descriptors(); | 1825 map->init_instance_descriptors(); |
1826 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); | 1826 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 // spaces. | 2166 // spaces. |
2167 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); | 2167 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); |
2168 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 2168 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
2169 | 2169 |
2170 Object* result; | 2170 Object* result; |
2171 { MaybeObject* maybe_result = | 2171 { MaybeObject* maybe_result = |
2172 AllocateRaw(HeapNumber::kSize, space, OLD_DATA_SPACE); | 2172 AllocateRaw(HeapNumber::kSize, space, OLD_DATA_SPACE); |
2173 if (!maybe_result->ToObject(&result)) return maybe_result; | 2173 if (!maybe_result->ToObject(&result)) return maybe_result; |
2174 } | 2174 } |
2175 | 2175 |
2176 HeapObject::cast(result)->set_map_unsafe(heap_number_map()); | 2176 HeapObject::cast(result)->set_map_no_wb(heap_number_map()); |
2177 HeapNumber::cast(result)->set_value(value); | 2177 HeapNumber::cast(result)->set_value(value); |
2178 return result; | 2178 return result; |
2179 } | 2179 } |
2180 | 2180 |
2181 | 2181 |
2182 MaybeObject* Heap::AllocateHeapNumber(double value) { | 2182 MaybeObject* Heap::AllocateHeapNumber(double value) { |
2183 // Use general version, if we're forced to always allocate. | 2183 // Use general version, if we're forced to always allocate. |
2184 if (always_allocate()) return AllocateHeapNumber(value, TENURED); | 2184 if (always_allocate()) return AllocateHeapNumber(value, TENURED); |
2185 | 2185 |
2186 // This version of AllocateHeapNumber is optimized for | 2186 // This version of AllocateHeapNumber is optimized for |
2187 // allocation in new space. | 2187 // allocation in new space. |
2188 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); | 2188 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); |
2189 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 2189 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
2190 Object* result; | 2190 Object* result; |
2191 { MaybeObject* maybe_result = new_space_.AllocateRaw(HeapNumber::kSize); | 2191 { MaybeObject* maybe_result = new_space_.AllocateRaw(HeapNumber::kSize); |
2192 if (!maybe_result->ToObject(&result)) return maybe_result; | 2192 if (!maybe_result->ToObject(&result)) return maybe_result; |
2193 } | 2193 } |
2194 HeapObject::cast(result)->set_map_unsafe(heap_number_map()); | 2194 HeapObject::cast(result)->set_map_no_wb(heap_number_map()); |
2195 HeapNumber::cast(result)->set_value(value); | 2195 HeapNumber::cast(result)->set_value(value); |
2196 return result; | 2196 return result; |
2197 } | 2197 } |
2198 | 2198 |
2199 | 2199 |
2200 MaybeObject* Heap::AllocateJSGlobalPropertyCell(Object* value) { | 2200 MaybeObject* Heap::AllocateJSGlobalPropertyCell(Object* value) { |
2201 Object* result; | 2201 Object* result; |
2202 { MaybeObject* maybe_result = AllocateRawCell(); | 2202 { MaybeObject* maybe_result = AllocateRawCell(); |
2203 if (!maybe_result->ToObject(&result)) return maybe_result; | 2203 if (!maybe_result->ToObject(&result)) return maybe_result; |
2204 } | 2204 } |
2205 HeapObject::cast(result)->set_map_unsafe(global_property_cell_map()); | 2205 HeapObject::cast(result)->set_map_no_wb(global_property_cell_map()); |
2206 JSGlobalPropertyCell::cast(result)->set_value(value); | 2206 JSGlobalPropertyCell::cast(result)->set_value(value); |
2207 return result; | 2207 return result; |
2208 } | 2208 } |
2209 | 2209 |
2210 | 2210 |
2211 MaybeObject* Heap::CreateOddball(const char* to_string, | 2211 MaybeObject* Heap::CreateOddball(const char* to_string, |
2212 Object* to_number, | 2212 Object* to_number, |
2213 byte kind) { | 2213 byte kind) { |
2214 Object* result; | 2214 Object* result; |
2215 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2215 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 if (array->length() < 100) { // Limit how many new symbols we want to make. | 2536 if (array->length() < 100) { // Limit how many new symbols we want to make. |
2537 for (int i = 0; i < array->length(); i++) { | 2537 for (int i = 0; i < array->length(); i++) { |
2538 String* str = String::cast(array->get(i)); | 2538 String* str = String::cast(array->get(i)); |
2539 Object* symbol; | 2539 Object* symbol; |
2540 MaybeObject* maybe_symbol = heap->LookupSymbol(str); | 2540 MaybeObject* maybe_symbol = heap->LookupSymbol(str); |
2541 if (maybe_symbol->ToObject(&symbol)) { | 2541 if (maybe_symbol->ToObject(&symbol)) { |
2542 array->set(i, symbol); | 2542 array->set(i, symbol); |
2543 } | 2543 } |
2544 } | 2544 } |
2545 } | 2545 } |
2546 array->set_map(heap->fixed_cow_array_map()); | 2546 array->set_map_no_wb(heap->fixed_cow_array_map()); |
2547 } | 2547 } |
2548 | 2548 |
2549 | 2549 |
2550 void StringSplitCache::Clear(FixedArray* cache) { | 2550 void StringSplitCache::Clear(FixedArray* cache) { |
2551 for (int i = 0; i < kStringSplitCacheSize; i++) { | 2551 for (int i = 0; i < kStringSplitCacheSize; i++) { |
2552 cache->set(i, Smi::FromInt(0)); | 2552 cache->set(i, Smi::FromInt(0)); |
2553 } | 2553 } |
2554 } | 2554 } |
2555 | 2555 |
2556 | 2556 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 return AllocateByteArray(length); | 3132 return AllocateByteArray(length); |
3133 } | 3133 } |
3134 int size = ByteArray::SizeFor(length); | 3134 int size = ByteArray::SizeFor(length); |
3135 Object* result; | 3135 Object* result; |
3136 { MaybeObject* maybe_result = (size <= MaxObjectSizeInPagedSpace()) | 3136 { MaybeObject* maybe_result = (size <= MaxObjectSizeInPagedSpace()) |
3137 ? old_data_space_->AllocateRaw(size) | 3137 ? old_data_space_->AllocateRaw(size) |
3138 : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); | 3138 : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); |
3139 if (!maybe_result->ToObject(&result)) return maybe_result; | 3139 if (!maybe_result->ToObject(&result)) return maybe_result; |
3140 } | 3140 } |
3141 | 3141 |
3142 reinterpret_cast<ByteArray*>(result)->set_map_unsafe(byte_array_map()); | 3142 reinterpret_cast<ByteArray*>(result)->set_map_no_wb(byte_array_map()); |
3143 reinterpret_cast<ByteArray*>(result)->set_length(length); | 3143 reinterpret_cast<ByteArray*>(result)->set_length(length); |
3144 return result; | 3144 return result; |
3145 } | 3145 } |
3146 | 3146 |
3147 | 3147 |
3148 MaybeObject* Heap::AllocateByteArray(int length) { | 3148 MaybeObject* Heap::AllocateByteArray(int length) { |
3149 if (length < 0 || length > ByteArray::kMaxLength) { | 3149 if (length < 0 || length > ByteArray::kMaxLength) { |
3150 return Failure::OutOfMemoryException(); | 3150 return Failure::OutOfMemoryException(); |
3151 } | 3151 } |
3152 int size = ByteArray::SizeFor(length); | 3152 int size = ByteArray::SizeFor(length); |
3153 AllocationSpace space = | 3153 AllocationSpace space = |
3154 (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : NEW_SPACE; | 3154 (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : NEW_SPACE; |
3155 Object* result; | 3155 Object* result; |
3156 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); | 3156 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); |
3157 if (!maybe_result->ToObject(&result)) return maybe_result; | 3157 if (!maybe_result->ToObject(&result)) return maybe_result; |
3158 } | 3158 } |
3159 | 3159 |
3160 reinterpret_cast<ByteArray*>(result)->set_map_unsafe(byte_array_map()); | 3160 reinterpret_cast<ByteArray*>(result)->set_map_no_wb(byte_array_map()); |
3161 reinterpret_cast<ByteArray*>(result)->set_length(length); | 3161 reinterpret_cast<ByteArray*>(result)->set_length(length); |
3162 return result; | 3162 return result; |
3163 } | 3163 } |
3164 | 3164 |
3165 | 3165 |
3166 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3166 void Heap::CreateFillerObjectAt(Address addr, int size) { |
3167 if (size == 0) return; | 3167 if (size == 0) return; |
3168 HeapObject* filler = HeapObject::FromAddress(addr); | 3168 HeapObject* filler = HeapObject::FromAddress(addr); |
3169 if (size == kPointerSize) { | 3169 if (size == kPointerSize) { |
3170 filler->set_map_unsafe(one_pointer_filler_map()); | 3170 filler->set_map_no_wb(one_pointer_filler_map()); |
3171 } else if (size == 2 * kPointerSize) { | 3171 } else if (size == 2 * kPointerSize) { |
3172 filler->set_map_unsafe(two_pointer_filler_map()); | 3172 filler->set_map_no_wb(two_pointer_filler_map()); |
3173 } else { | 3173 } else { |
3174 filler->set_map_unsafe(free_space_map()); | 3174 filler->set_map_no_wb(free_space_map()); |
3175 FreeSpace::cast(filler)->set_size(size); | 3175 FreeSpace::cast(filler)->set_size(size); |
3176 } | 3176 } |
3177 } | 3177 } |
3178 | 3178 |
3179 | 3179 |
3180 MaybeObject* Heap::AllocateExternalArray(int length, | 3180 MaybeObject* Heap::AllocateExternalArray(int length, |
3181 ExternalArrayType array_type, | 3181 ExternalArrayType array_type, |
3182 void* external_pointer, | 3182 void* external_pointer, |
3183 PretenureFlag pretenure) { | 3183 PretenureFlag pretenure) { |
3184 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 3184 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
3185 Object* result; | 3185 Object* result; |
3186 { MaybeObject* maybe_result = AllocateRaw(ExternalArray::kAlignedSize, | 3186 { MaybeObject* maybe_result = AllocateRaw(ExternalArray::kAlignedSize, |
3187 space, | 3187 space, |
3188 OLD_DATA_SPACE); | 3188 OLD_DATA_SPACE); |
3189 if (!maybe_result->ToObject(&result)) return maybe_result; | 3189 if (!maybe_result->ToObject(&result)) return maybe_result; |
3190 } | 3190 } |
3191 | 3191 |
3192 reinterpret_cast<ExternalArray*>(result)->set_map_unsafe( | 3192 reinterpret_cast<ExternalArray*>(result)->set_map_no_wb( |
3193 MapForExternalArrayType(array_type)); | 3193 MapForExternalArrayType(array_type)); |
3194 reinterpret_cast<ExternalArray*>(result)->set_length(length); | 3194 reinterpret_cast<ExternalArray*>(result)->set_length(length); |
3195 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( | 3195 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( |
3196 external_pointer); | 3196 external_pointer); |
3197 | 3197 |
3198 return result; | 3198 return result; |
3199 } | 3199 } |
3200 | 3200 |
3201 | 3201 |
3202 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 3202 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
(...skipping 16 matching lines...) Expand all Loading... |
3219 if (obj_size > MaxObjectSizeInPagedSpace() || immovable) { | 3219 if (obj_size > MaxObjectSizeInPagedSpace() || immovable) { |
3220 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); | 3220 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); |
3221 } else { | 3221 } else { |
3222 maybe_result = code_space_->AllocateRaw(obj_size); | 3222 maybe_result = code_space_->AllocateRaw(obj_size); |
3223 } | 3223 } |
3224 | 3224 |
3225 Object* result; | 3225 Object* result; |
3226 if (!maybe_result->ToObject(&result)) return maybe_result; | 3226 if (!maybe_result->ToObject(&result)) return maybe_result; |
3227 | 3227 |
3228 // Initialize the object | 3228 // Initialize the object |
3229 HeapObject::cast(result)->set_map_unsafe(code_map()); | 3229 HeapObject::cast(result)->set_map_no_wb(code_map()); |
3230 Code* code = Code::cast(result); | 3230 Code* code = Code::cast(result); |
3231 ASSERT(!isolate_->code_range()->exists() || | 3231 ASSERT(!isolate_->code_range()->exists() || |
3232 isolate_->code_range()->contains(code->address())); | 3232 isolate_->code_range()->contains(code->address())); |
3233 code->set_instruction_size(desc.instr_size); | 3233 code->set_instruction_size(desc.instr_size); |
3234 code->set_relocation_info(reloc_info); | 3234 code->set_relocation_info(reloc_info); |
3235 code->set_flags(flags); | 3235 code->set_flags(flags); |
3236 if (code->is_call_stub() || code->is_keyed_call_stub()) { | 3236 if (code->is_call_stub() || code->is_keyed_call_stub()) { |
3237 code->set_check_type(RECEIVER_MAP_CHECK); | 3237 code->set_check_type(RECEIVER_MAP_CHECK); |
3238 } | 3238 } |
3239 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); | 3239 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3348 // If allocation failures are disallowed, we may allocate in a different | 3348 // If allocation failures are disallowed, we may allocate in a different |
3349 // space when new space is full and the object is not a large object. | 3349 // space when new space is full and the object is not a large object. |
3350 AllocationSpace retry_space = | 3350 AllocationSpace retry_space = |
3351 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); | 3351 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); |
3352 Object* result; | 3352 Object* result; |
3353 { MaybeObject* maybe_result = | 3353 { MaybeObject* maybe_result = |
3354 AllocateRaw(map->instance_size(), space, retry_space); | 3354 AllocateRaw(map->instance_size(), space, retry_space); |
3355 if (!maybe_result->ToObject(&result)) return maybe_result; | 3355 if (!maybe_result->ToObject(&result)) return maybe_result; |
3356 } | 3356 } |
3357 // No need for write barrier since object is white and map is in old space. | 3357 // No need for write barrier since object is white and map is in old space. |
3358 HeapObject::cast(result)->set_map_unsafe(map); | 3358 HeapObject::cast(result)->set_map_no_wb(map); |
3359 return result; | 3359 return result; |
3360 } | 3360 } |
3361 | 3361 |
3362 | 3362 |
3363 void Heap::InitializeFunction(JSFunction* function, | 3363 void Heap::InitializeFunction(JSFunction* function, |
3364 SharedFunctionInfo* shared, | 3364 SharedFunctionInfo* shared, |
3365 Object* prototype) { | 3365 Object* prototype) { |
3366 ASSERT(!prototype->IsMap()); | 3366 ASSERT(!prototype->IsMap()); |
3367 function->initialize_properties(); | 3367 function->initialize_properties(); |
3368 function->initialize_elements(); | 3368 function->initialize_elements(); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4077 } | 4077 } |
4078 | 4078 |
4079 // Allocate string. | 4079 // Allocate string. |
4080 Object* result; | 4080 Object* result; |
4081 { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace()) | 4081 { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace()) |
4082 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) | 4082 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) |
4083 : old_data_space_->AllocateRaw(size); | 4083 : old_data_space_->AllocateRaw(size); |
4084 if (!maybe_result->ToObject(&result)) return maybe_result; | 4084 if (!maybe_result->ToObject(&result)) return maybe_result; |
4085 } | 4085 } |
4086 | 4086 |
4087 reinterpret_cast<HeapObject*>(result)->set_map_unsafe(map); | 4087 reinterpret_cast<HeapObject*>(result)->set_map_no_wb(map); |
4088 // Set length and hash fields of the allocated string. | 4088 // Set length and hash fields of the allocated string. |
4089 String* answer = String::cast(result); | 4089 String* answer = String::cast(result); |
4090 answer->set_length(chars); | 4090 answer->set_length(chars); |
4091 answer->set_hash_field(hash_field); | 4091 answer->set_hash_field(hash_field); |
4092 | 4092 |
4093 ASSERT_EQ(size, answer->Size()); | 4093 ASSERT_EQ(size, answer->Size()); |
4094 | 4094 |
4095 // Fill in the characters. | 4095 // Fill in the characters. |
4096 for (int i = 0; i < chars; i++) { | 4096 for (int i = 0; i < chars; i++) { |
4097 answer->Set(i, buffer->GetNext()); | 4097 answer->Set(i, buffer->GetNext()); |
(...skipping 23 matching lines...) Expand all Loading... |
4121 } | 4121 } |
4122 } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { | 4122 } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { |
4123 space = LO_SPACE; | 4123 space = LO_SPACE; |
4124 } | 4124 } |
4125 Object* result; | 4125 Object* result; |
4126 { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); | 4126 { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); |
4127 if (!maybe_result->ToObject(&result)) return maybe_result; | 4127 if (!maybe_result->ToObject(&result)) return maybe_result; |
4128 } | 4128 } |
4129 | 4129 |
4130 // Partially initialize the object. | 4130 // Partially initialize the object. |
4131 HeapObject::cast(result)->set_map_unsafe(ascii_string_map()); | 4131 HeapObject::cast(result)->set_map_no_wb(ascii_string_map()); |
4132 String::cast(result)->set_length(length); | 4132 String::cast(result)->set_length(length); |
4133 String::cast(result)->set_hash_field(String::kEmptyHashField); | 4133 String::cast(result)->set_hash_field(String::kEmptyHashField); |
4134 ASSERT_EQ(size, HeapObject::cast(result)->Size()); | 4134 ASSERT_EQ(size, HeapObject::cast(result)->Size()); |
4135 return result; | 4135 return result; |
4136 } | 4136 } |
4137 | 4137 |
4138 | 4138 |
4139 MaybeObject* Heap::AllocateRawTwoByteString(int length, | 4139 MaybeObject* Heap::AllocateRawTwoByteString(int length, |
4140 PretenureFlag pretenure) { | 4140 PretenureFlag pretenure) { |
4141 if (length < 0 || length > SeqTwoByteString::kMaxLength) { | 4141 if (length < 0 || length > SeqTwoByteString::kMaxLength) { |
(...skipping 14 matching lines...) Expand all Loading... |
4156 } | 4156 } |
4157 } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { | 4157 } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { |
4158 space = LO_SPACE; | 4158 space = LO_SPACE; |
4159 } | 4159 } |
4160 Object* result; | 4160 Object* result; |
4161 { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); | 4161 { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); |
4162 if (!maybe_result->ToObject(&result)) return maybe_result; | 4162 if (!maybe_result->ToObject(&result)) return maybe_result; |
4163 } | 4163 } |
4164 | 4164 |
4165 // Partially initialize the object. | 4165 // Partially initialize the object. |
4166 HeapObject::cast(result)->set_map_unsafe(string_map()); | 4166 HeapObject::cast(result)->set_map_no_wb(string_map()); |
4167 String::cast(result)->set_length(length); | 4167 String::cast(result)->set_length(length); |
4168 String::cast(result)->set_hash_field(String::kEmptyHashField); | 4168 String::cast(result)->set_hash_field(String::kEmptyHashField); |
4169 ASSERT_EQ(size, HeapObject::cast(result)->Size()); | 4169 ASSERT_EQ(size, HeapObject::cast(result)->Size()); |
4170 return result; | 4170 return result; |
4171 } | 4171 } |
4172 | 4172 |
4173 | 4173 |
4174 MaybeObject* Heap::AllocateEmptyFixedArray() { | 4174 MaybeObject* Heap::AllocateEmptyFixedArray() { |
4175 int size = FixedArray::SizeFor(0); | 4175 int size = FixedArray::SizeFor(0); |
4176 Object* result; | 4176 Object* result; |
4177 { MaybeObject* maybe_result = | 4177 { MaybeObject* maybe_result = |
4178 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); | 4178 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
4179 if (!maybe_result->ToObject(&result)) return maybe_result; | 4179 if (!maybe_result->ToObject(&result)) return maybe_result; |
4180 } | 4180 } |
4181 // Initialize the object. | 4181 // Initialize the object. |
4182 reinterpret_cast<FixedArray*>(result)->set_map_unsafe(fixed_array_map()); | 4182 reinterpret_cast<FixedArray*>(result)->set_map_no_wb(fixed_array_map()); |
4183 reinterpret_cast<FixedArray*>(result)->set_length(0); | 4183 reinterpret_cast<FixedArray*>(result)->set_length(0); |
4184 return result; | 4184 return result; |
4185 } | 4185 } |
4186 | 4186 |
4187 | 4187 |
4188 MaybeObject* Heap::AllocateRawFixedArray(int length) { | 4188 MaybeObject* Heap::AllocateRawFixedArray(int length) { |
4189 if (length < 0 || length > FixedArray::kMaxLength) { | 4189 if (length < 0 || length > FixedArray::kMaxLength) { |
4190 return Failure::OutOfMemoryException(); | 4190 return Failure::OutOfMemoryException(); |
4191 } | 4191 } |
4192 ASSERT(length > 0); | 4192 ASSERT(length > 0); |
4193 // Use the general function if we're forced to always allocate. | 4193 // Use the general function if we're forced to always allocate. |
4194 if (always_allocate()) return AllocateFixedArray(length, TENURED); | 4194 if (always_allocate()) return AllocateFixedArray(length, TENURED); |
4195 // Allocate the raw data for a fixed array. | 4195 // Allocate the raw data for a fixed array. |
4196 int size = FixedArray::SizeFor(length); | 4196 int size = FixedArray::SizeFor(length); |
4197 return size <= kMaxObjectSizeInNewSpace | 4197 return size <= kMaxObjectSizeInNewSpace |
4198 ? new_space_.AllocateRaw(size) | 4198 ? new_space_.AllocateRaw(size) |
4199 : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); | 4199 : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); |
4200 } | 4200 } |
4201 | 4201 |
4202 | 4202 |
4203 MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { | 4203 MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
4204 int len = src->length(); | 4204 int len = src->length(); |
4205 Object* obj; | 4205 Object* obj; |
4206 { MaybeObject* maybe_obj = AllocateRawFixedArray(len); | 4206 { MaybeObject* maybe_obj = AllocateRawFixedArray(len); |
4207 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4207 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
4208 } | 4208 } |
4209 if (InNewSpace(obj)) { | 4209 if (InNewSpace(obj)) { |
4210 HeapObject* dst = HeapObject::cast(obj); | 4210 HeapObject* dst = HeapObject::cast(obj); |
4211 dst->set_map_unsafe(map); | 4211 dst->set_map_no_wb(map); |
4212 CopyBlock(dst->address() + kPointerSize, | 4212 CopyBlock(dst->address() + kPointerSize, |
4213 src->address() + kPointerSize, | 4213 src->address() + kPointerSize, |
4214 FixedArray::SizeFor(len) - kPointerSize); | 4214 FixedArray::SizeFor(len) - kPointerSize); |
4215 return obj; | 4215 return obj; |
4216 } | 4216 } |
4217 HeapObject::cast(obj)->set_map_unsafe(map); | 4217 HeapObject::cast(obj)->set_map_no_wb(map); |
4218 FixedArray* result = FixedArray::cast(obj); | 4218 FixedArray* result = FixedArray::cast(obj); |
4219 result->set_length(len); | 4219 result->set_length(len); |
4220 | 4220 |
4221 // Copy the content | 4221 // Copy the content |
4222 AssertNoAllocation no_gc; | 4222 AssertNoAllocation no_gc; |
4223 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 4223 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
4224 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); | 4224 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
4225 return result; | 4225 return result; |
4226 } | 4226 } |
4227 | 4227 |
4228 | 4228 |
4229 MaybeObject* Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, | 4229 MaybeObject* Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, |
4230 Map* map) { | 4230 Map* map) { |
4231 int len = src->length(); | 4231 int len = src->length(); |
4232 Object* obj; | 4232 Object* obj; |
4233 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(len, NOT_TENURED); | 4233 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(len, NOT_TENURED); |
4234 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4234 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
4235 } | 4235 } |
4236 HeapObject* dst = HeapObject::cast(obj); | 4236 HeapObject* dst = HeapObject::cast(obj); |
4237 dst->set_map_unsafe(map); | 4237 dst->set_map_no_wb(map); |
4238 CopyBlock( | 4238 CopyBlock( |
4239 dst->address() + FixedDoubleArray::kLengthOffset, | 4239 dst->address() + FixedDoubleArray::kLengthOffset, |
4240 src->address() + FixedDoubleArray::kLengthOffset, | 4240 src->address() + FixedDoubleArray::kLengthOffset, |
4241 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); | 4241 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); |
4242 return obj; | 4242 return obj; |
4243 } | 4243 } |
4244 | 4244 |
4245 | 4245 |
4246 MaybeObject* Heap::AllocateFixedArray(int length) { | 4246 MaybeObject* Heap::AllocateFixedArray(int length) { |
4247 ASSERT(length >= 0); | 4247 ASSERT(length >= 0); |
4248 if (length == 0) return empty_fixed_array(); | 4248 if (length == 0) return empty_fixed_array(); |
4249 Object* result; | 4249 Object* result; |
4250 { MaybeObject* maybe_result = AllocateRawFixedArray(length); | 4250 { MaybeObject* maybe_result = AllocateRawFixedArray(length); |
4251 if (!maybe_result->ToObject(&result)) return maybe_result; | 4251 if (!maybe_result->ToObject(&result)) return maybe_result; |
4252 } | 4252 } |
4253 // Initialize header. | 4253 // Initialize header. |
4254 FixedArray* array = reinterpret_cast<FixedArray*>(result); | 4254 FixedArray* array = reinterpret_cast<FixedArray*>(result); |
4255 array->set_map_unsafe(fixed_array_map()); | 4255 array->set_map_no_wb(fixed_array_map()); |
4256 array->set_length(length); | 4256 array->set_length(length); |
4257 // Initialize body. | 4257 // Initialize body. |
4258 ASSERT(!InNewSpace(undefined_value())); | 4258 ASSERT(!InNewSpace(undefined_value())); |
4259 MemsetPointer(array->data_start(), undefined_value(), length); | 4259 MemsetPointer(array->data_start(), undefined_value(), length); |
4260 return result; | 4260 return result; |
4261 } | 4261 } |
4262 | 4262 |
4263 | 4263 |
4264 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { | 4264 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { |
4265 if (length < 0 || length > FixedArray::kMaxLength) { | 4265 if (length < 0 || length > FixedArray::kMaxLength) { |
(...skipping 27 matching lines...) Expand all Loading... |
4293 ASSERT(length >= 0); | 4293 ASSERT(length >= 0); |
4294 ASSERT(heap->empty_fixed_array()->IsFixedArray()); | 4294 ASSERT(heap->empty_fixed_array()->IsFixedArray()); |
4295 if (length == 0) return heap->empty_fixed_array(); | 4295 if (length == 0) return heap->empty_fixed_array(); |
4296 | 4296 |
4297 ASSERT(!heap->InNewSpace(filler)); | 4297 ASSERT(!heap->InNewSpace(filler)); |
4298 Object* result; | 4298 Object* result; |
4299 { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); | 4299 { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); |
4300 if (!maybe_result->ToObject(&result)) return maybe_result; | 4300 if (!maybe_result->ToObject(&result)) return maybe_result; |
4301 } | 4301 } |
4302 | 4302 |
4303 HeapObject::cast(result)->set_map_unsafe(heap->fixed_array_map()); | 4303 HeapObject::cast(result)->set_map_no_wb(heap->fixed_array_map()); |
4304 FixedArray* array = FixedArray::cast(result); | 4304 FixedArray* array = FixedArray::cast(result); |
4305 array->set_length(length); | 4305 array->set_length(length); |
4306 MemsetPointer(array->data_start(), filler, length); | 4306 MemsetPointer(array->data_start(), filler, length); |
4307 return array; | 4307 return array; |
4308 } | 4308 } |
4309 | 4309 |
4310 | 4310 |
4311 MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { | 4311 MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { |
4312 return AllocateFixedArrayWithFiller(this, | 4312 return AllocateFixedArrayWithFiller(this, |
4313 length, | 4313 length, |
(...skipping 12 matching lines...) Expand all Loading... |
4326 | 4326 |
4327 | 4327 |
4328 MaybeObject* Heap::AllocateUninitializedFixedArray(int length) { | 4328 MaybeObject* Heap::AllocateUninitializedFixedArray(int length) { |
4329 if (length == 0) return empty_fixed_array(); | 4329 if (length == 0) return empty_fixed_array(); |
4330 | 4330 |
4331 Object* obj; | 4331 Object* obj; |
4332 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); | 4332 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); |
4333 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4333 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
4334 } | 4334 } |
4335 | 4335 |
4336 reinterpret_cast<FixedArray*>(obj)->set_map_unsafe(fixed_array_map()); | 4336 reinterpret_cast<FixedArray*>(obj)->set_map_no_wb(fixed_array_map()); |
4337 FixedArray::cast(obj)->set_length(length); | 4337 FixedArray::cast(obj)->set_length(length); |
4338 return obj; | 4338 return obj; |
4339 } | 4339 } |
4340 | 4340 |
4341 | 4341 |
4342 MaybeObject* Heap::AllocateEmptyFixedDoubleArray() { | 4342 MaybeObject* Heap::AllocateEmptyFixedDoubleArray() { |
4343 int size = FixedDoubleArray::SizeFor(0); | 4343 int size = FixedDoubleArray::SizeFor(0); |
4344 Object* result; | 4344 Object* result; |
4345 { MaybeObject* maybe_result = | 4345 { MaybeObject* maybe_result = |
4346 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); | 4346 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
4347 if (!maybe_result->ToObject(&result)) return maybe_result; | 4347 if (!maybe_result->ToObject(&result)) return maybe_result; |
4348 } | 4348 } |
4349 // Initialize the object. | 4349 // Initialize the object. |
4350 reinterpret_cast<FixedDoubleArray*>(result)->set_map_unsafe( | 4350 reinterpret_cast<FixedDoubleArray*>(result)->set_map_no_wb( |
4351 fixed_double_array_map()); | 4351 fixed_double_array_map()); |
4352 reinterpret_cast<FixedDoubleArray*>(result)->set_length(0); | 4352 reinterpret_cast<FixedDoubleArray*>(result)->set_length(0); |
4353 return result; | 4353 return result; |
4354 } | 4354 } |
4355 | 4355 |
4356 | 4356 |
4357 MaybeObject* Heap::AllocateUninitializedFixedDoubleArray( | 4357 MaybeObject* Heap::AllocateUninitializedFixedDoubleArray( |
4358 int length, | 4358 int length, |
4359 PretenureFlag pretenure) { | 4359 PretenureFlag pretenure) { |
4360 if (length == 0) return empty_fixed_double_array(); | 4360 if (length == 0) return empty_fixed_double_array(); |
4361 | 4361 |
4362 Object* obj; | 4362 Object* obj; |
4363 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure); | 4363 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure); |
4364 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4364 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
4365 } | 4365 } |
4366 | 4366 |
4367 reinterpret_cast<FixedDoubleArray*>(obj)->set_map_unsafe( | 4367 reinterpret_cast<FixedDoubleArray*>(obj)->set_map_no_wb( |
4368 fixed_double_array_map()); | 4368 fixed_double_array_map()); |
4369 FixedDoubleArray::cast(obj)->set_length(length); | 4369 FixedDoubleArray::cast(obj)->set_length(length); |
4370 return obj; | 4370 return obj; |
4371 } | 4371 } |
4372 | 4372 |
4373 | 4373 |
4374 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length, | 4374 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length, |
4375 PretenureFlag pretenure) { | 4375 PretenureFlag pretenure) { |
4376 if (length < 0 || length > FixedDoubleArray::kMaxLength) { | 4376 if (length < 0 || length > FixedDoubleArray::kMaxLength) { |
4377 return Failure::OutOfMemoryException(); | 4377 return Failure::OutOfMemoryException(); |
(...skipping 16 matching lines...) Expand all Loading... |
4394 | 4394 |
4395 return AllocateRaw(size, space, retry_space); | 4395 return AllocateRaw(size, space, retry_space); |
4396 } | 4396 } |
4397 | 4397 |
4398 | 4398 |
4399 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { | 4399 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { |
4400 Object* result; | 4400 Object* result; |
4401 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); | 4401 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); |
4402 if (!maybe_result->ToObject(&result)) return maybe_result; | 4402 if (!maybe_result->ToObject(&result)) return maybe_result; |
4403 } | 4403 } |
4404 reinterpret_cast<HeapObject*>(result)->set_map_unsafe(hash_table_map()); | 4404 reinterpret_cast<HeapObject*>(result)->set_map_no_wb(hash_table_map()); |
4405 ASSERT(result->IsHashTable()); | 4405 ASSERT(result->IsHashTable()); |
4406 return result; | 4406 return result; |
4407 } | 4407 } |
4408 | 4408 |
4409 | 4409 |
4410 MaybeObject* Heap::AllocateGlobalContext() { | 4410 MaybeObject* Heap::AllocateGlobalContext() { |
4411 Object* result; | 4411 Object* result; |
4412 { MaybeObject* maybe_result = | 4412 { MaybeObject* maybe_result = |
4413 AllocateFixedArray(Context::GLOBAL_CONTEXT_SLOTS); | 4413 AllocateFixedArray(Context::GLOBAL_CONTEXT_SLOTS); |
4414 if (!maybe_result->ToObject(&result)) return maybe_result; | 4414 if (!maybe_result->ToObject(&result)) return maybe_result; |
4415 } | 4415 } |
4416 Context* context = reinterpret_cast<Context*>(result); | 4416 Context* context = reinterpret_cast<Context*>(result); |
4417 context->set_map_unsafe(global_context_map()); | 4417 context->set_map_no_wb(global_context_map()); |
4418 ASSERT(context->IsGlobalContext()); | 4418 ASSERT(context->IsGlobalContext()); |
4419 ASSERT(result->IsContext()); | 4419 ASSERT(result->IsContext()); |
4420 return result; | 4420 return result; |
4421 } | 4421 } |
4422 | 4422 |
4423 | 4423 |
4424 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { | 4424 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { |
4425 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); | 4425 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); |
4426 Object* result; | 4426 Object* result; |
4427 { MaybeObject* maybe_result = AllocateFixedArray(length); | 4427 { MaybeObject* maybe_result = AllocateFixedArray(length); |
4428 if (!maybe_result->ToObject(&result)) return maybe_result; | 4428 if (!maybe_result->ToObject(&result)) return maybe_result; |
4429 } | 4429 } |
4430 Context* context = reinterpret_cast<Context*>(result); | 4430 Context* context = reinterpret_cast<Context*>(result); |
4431 context->set_map_unsafe(function_context_map()); | 4431 context->set_map_no_wb(function_context_map()); |
4432 context->set_closure(function); | 4432 context->set_closure(function); |
4433 context->set_previous(function->context()); | 4433 context->set_previous(function->context()); |
4434 context->set_extension(NULL); | 4434 context->set_extension(NULL); |
4435 context->set_global(function->context()->global()); | 4435 context->set_global(function->context()->global()); |
4436 return context; | 4436 return context; |
4437 } | 4437 } |
4438 | 4438 |
4439 | 4439 |
4440 MaybeObject* Heap::AllocateCatchContext(JSFunction* function, | 4440 MaybeObject* Heap::AllocateCatchContext(JSFunction* function, |
4441 Context* previous, | 4441 Context* previous, |
4442 String* name, | 4442 String* name, |
4443 Object* thrown_object) { | 4443 Object* thrown_object) { |
4444 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); | 4444 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); |
4445 Object* result; | 4445 Object* result; |
4446 { MaybeObject* maybe_result = | 4446 { MaybeObject* maybe_result = |
4447 AllocateFixedArray(Context::MIN_CONTEXT_SLOTS + 1); | 4447 AllocateFixedArray(Context::MIN_CONTEXT_SLOTS + 1); |
4448 if (!maybe_result->ToObject(&result)) return maybe_result; | 4448 if (!maybe_result->ToObject(&result)) return maybe_result; |
4449 } | 4449 } |
4450 Context* context = reinterpret_cast<Context*>(result); | 4450 Context* context = reinterpret_cast<Context*>(result); |
4451 context->set_map_unsafe(catch_context_map()); | 4451 context->set_map_no_wb(catch_context_map()); |
4452 context->set_closure(function); | 4452 context->set_closure(function); |
4453 context->set_previous(previous); | 4453 context->set_previous(previous); |
4454 context->set_extension(name); | 4454 context->set_extension(name); |
4455 context->set_global(previous->global()); | 4455 context->set_global(previous->global()); |
4456 context->set(Context::THROWN_OBJECT_INDEX, thrown_object); | 4456 context->set(Context::THROWN_OBJECT_INDEX, thrown_object); |
4457 return context; | 4457 return context; |
4458 } | 4458 } |
4459 | 4459 |
4460 | 4460 |
4461 MaybeObject* Heap::AllocateWithContext(JSFunction* function, | 4461 MaybeObject* Heap::AllocateWithContext(JSFunction* function, |
4462 Context* previous, | 4462 Context* previous, |
4463 JSObject* extension) { | 4463 JSObject* extension) { |
4464 Object* result; | 4464 Object* result; |
4465 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); | 4465 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); |
4466 if (!maybe_result->ToObject(&result)) return maybe_result; | 4466 if (!maybe_result->ToObject(&result)) return maybe_result; |
4467 } | 4467 } |
4468 Context* context = reinterpret_cast<Context*>(result); | 4468 Context* context = reinterpret_cast<Context*>(result); |
4469 context->set_map_unsafe(with_context_map()); | 4469 context->set_map_no_wb(with_context_map()); |
4470 context->set_closure(function); | 4470 context->set_closure(function); |
4471 context->set_previous(previous); | 4471 context->set_previous(previous); |
4472 context->set_extension(extension); | 4472 context->set_extension(extension); |
4473 context->set_global(previous->global()); | 4473 context->set_global(previous->global()); |
4474 return context; | 4474 return context; |
4475 } | 4475 } |
4476 | 4476 |
4477 | 4477 |
4478 MaybeObject* Heap::AllocateBlockContext(JSFunction* function, | 4478 MaybeObject* Heap::AllocateBlockContext(JSFunction* function, |
4479 Context* previous, | 4479 Context* previous, |
4480 ScopeInfo* scope_info) { | 4480 ScopeInfo* scope_info) { |
4481 Object* result; | 4481 Object* result; |
4482 { MaybeObject* maybe_result = | 4482 { MaybeObject* maybe_result = |
4483 AllocateFixedArrayWithHoles(scope_info->ContextLength()); | 4483 AllocateFixedArrayWithHoles(scope_info->ContextLength()); |
4484 if (!maybe_result->ToObject(&result)) return maybe_result; | 4484 if (!maybe_result->ToObject(&result)) return maybe_result; |
4485 } | 4485 } |
4486 Context* context = reinterpret_cast<Context*>(result); | 4486 Context* context = reinterpret_cast<Context*>(result); |
4487 context->set_map_unsafe(block_context_map()); | 4487 context->set_map_no_wb(block_context_map()); |
4488 context->set_closure(function); | 4488 context->set_closure(function); |
4489 context->set_previous(previous); | 4489 context->set_previous(previous); |
4490 context->set_extension(scope_info); | 4490 context->set_extension(scope_info); |
4491 context->set_global(previous->global()); | 4491 context->set_global(previous->global()); |
4492 return context; | 4492 return context; |
4493 } | 4493 } |
4494 | 4494 |
4495 | 4495 |
4496 MaybeObject* Heap::AllocateScopeInfo(int length) { | 4496 MaybeObject* Heap::AllocateScopeInfo(int length) { |
4497 FixedArray* scope_info; | 4497 FixedArray* scope_info; |
4498 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); | 4498 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); |
4499 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; | 4499 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; |
4500 scope_info->set_map_unsafe(scope_info_map()); | 4500 scope_info->set_map_no_wb(scope_info_map()); |
4501 return scope_info; | 4501 return scope_info; |
4502 } | 4502 } |
4503 | 4503 |
4504 | 4504 |
4505 MaybeObject* Heap::AllocateStruct(InstanceType type) { | 4505 MaybeObject* Heap::AllocateStruct(InstanceType type) { |
4506 Map* map; | 4506 Map* map; |
4507 switch (type) { | 4507 switch (type) { |
4508 #define MAKE_CASE(NAME, Name, name) \ | 4508 #define MAKE_CASE(NAME, Name, name) \ |
4509 case NAME##_TYPE: map = name##_map(); break; | 4509 case NAME##_TYPE: map = name##_map(); break; |
4510 STRUCT_LIST(MAKE_CASE) | 4510 STRUCT_LIST(MAKE_CASE) |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5407 (!search_for_any_global_ && (obj == search_target_))) { | 5407 (!search_for_any_global_ && (obj == search_target_))) { |
5408 found_target_ = true; | 5408 found_target_ = true; |
5409 return; | 5409 return; |
5410 } | 5410 } |
5411 | 5411 |
5412 // not visited yet | 5412 // not visited yet |
5413 Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); | 5413 Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); |
5414 | 5414 |
5415 Address map_addr = map_p->address(); | 5415 Address map_addr = map_p->address(); |
5416 | 5416 |
5417 obj->set_map(reinterpret_cast<Map*>(map_addr + kMarkTag)); | 5417 obj->set_map_no_wb(reinterpret_cast<Map*>(map_addr + kMarkTag)); |
5418 | 5418 |
5419 MarkObjectRecursively(&map); | 5419 MarkObjectRecursively(&map); |
5420 | 5420 |
5421 MarkObjectVisitor mark_visitor(this); | 5421 MarkObjectVisitor mark_visitor(this); |
5422 | 5422 |
5423 obj->IterateBody(map_p->instance_type(), obj->SizeFromMap(map_p), | 5423 obj->IterateBody(map_p->instance_type(), obj->SizeFromMap(map_p), |
5424 &mark_visitor); | 5424 &mark_visitor); |
5425 | 5425 |
5426 if (!found_target_) // don't pop if found the target | 5426 if (!found_target_) // don't pop if found the target |
5427 object_stack_.RemoveLast(); | 5427 object_stack_.RemoveLast(); |
(...skipping 26 matching lines...) Expand all Loading... |
5454 if (map->IsHeapObject()) return; // unmarked already | 5454 if (map->IsHeapObject()) return; // unmarked already |
5455 | 5455 |
5456 Address map_addr = reinterpret_cast<Address>(map); | 5456 Address map_addr = reinterpret_cast<Address>(map); |
5457 | 5457 |
5458 map_addr -= kMarkTag; | 5458 map_addr -= kMarkTag; |
5459 | 5459 |
5460 ASSERT_TAG_ALIGNED(map_addr); | 5460 ASSERT_TAG_ALIGNED(map_addr); |
5461 | 5461 |
5462 HeapObject* map_p = HeapObject::FromAddress(map_addr); | 5462 HeapObject* map_p = HeapObject::FromAddress(map_addr); |
5463 | 5463 |
5464 obj->set_map(reinterpret_cast<Map*>(map_p)); | 5464 obj->set_map_no_wb(reinterpret_cast<Map*>(map_p)); |
5465 | 5465 |
5466 UnmarkObjectRecursively(reinterpret_cast<Object**>(&map_p)); | 5466 UnmarkObjectRecursively(reinterpret_cast<Object**>(&map_p)); |
5467 | 5467 |
5468 UnmarkObjectVisitor unmark_visitor(this); | 5468 UnmarkObjectVisitor unmark_visitor(this); |
5469 | 5469 |
5470 obj->IterateBody(Map::cast(map_p)->instance_type(), | 5470 obj->IterateBody(Map::cast(map_p)->instance_type(), |
5471 obj->SizeFromMap(Map::cast(map_p)), | 5471 obj->SizeFromMap(Map::cast(map_p)), |
5472 &unmark_visitor); | 5472 &unmark_visitor); |
5473 } | 5473 } |
5474 | 5474 |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6166 return; | 6166 return; |
6167 } | 6167 } |
6168 | 6168 |
6169 bool is_global_context = SafeIsGlobalContext(obj); | 6169 bool is_global_context = SafeIsGlobalContext(obj); |
6170 | 6170 |
6171 // not visited yet | 6171 // not visited yet |
6172 Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); | 6172 Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); |
6173 | 6173 |
6174 Address map_addr = map_p->address(); | 6174 Address map_addr = map_p->address(); |
6175 | 6175 |
6176 obj->set_map(reinterpret_cast<Map*>(map_addr + kMarkTag)); | 6176 obj->set_map_no_wb(reinterpret_cast<Map*>(map_addr + kMarkTag)); |
6177 | 6177 |
6178 // Scan the object body. | 6178 // Scan the object body. |
6179 if (is_global_context && (visit_mode_ == VISIT_ONLY_STRONG)) { | 6179 if (is_global_context && (visit_mode_ == VISIT_ONLY_STRONG)) { |
6180 // This is specialized to scan Context's properly. | 6180 // This is specialized to scan Context's properly. |
6181 Object** start = reinterpret_cast<Object**>(obj->address() + | 6181 Object** start = reinterpret_cast<Object**>(obj->address() + |
6182 Context::kHeaderSize); | 6182 Context::kHeaderSize); |
6183 Object** end = reinterpret_cast<Object**>(obj->address() + | 6183 Object** end = reinterpret_cast<Object**>(obj->address() + |
6184 Context::kHeaderSize + Context::FIRST_WEAK_SLOT * kPointerSize); | 6184 Context::kHeaderSize + Context::FIRST_WEAK_SLOT * kPointerSize); |
6185 mark_visitor->VisitPointers(start, end); | 6185 mark_visitor->VisitPointers(start, end); |
6186 } else { | 6186 } else { |
(...skipping 21 matching lines...) Expand all Loading... |
6208 if (map->IsHeapObject()) return; // unmarked already | 6208 if (map->IsHeapObject()) return; // unmarked already |
6209 | 6209 |
6210 Address map_addr = reinterpret_cast<Address>(map); | 6210 Address map_addr = reinterpret_cast<Address>(map); |
6211 | 6211 |
6212 map_addr -= kMarkTag; | 6212 map_addr -= kMarkTag; |
6213 | 6213 |
6214 ASSERT_TAG_ALIGNED(map_addr); | 6214 ASSERT_TAG_ALIGNED(map_addr); |
6215 | 6215 |
6216 HeapObject* map_p = HeapObject::FromAddress(map_addr); | 6216 HeapObject* map_p = HeapObject::FromAddress(map_addr); |
6217 | 6217 |
6218 obj->set_map(reinterpret_cast<Map*>(map_p)); | 6218 obj->set_map_no_wb(reinterpret_cast<Map*>(map_p)); |
6219 | 6219 |
6220 UnmarkRecursively(reinterpret_cast<Object**>(&map_p), unmark_visitor); | 6220 UnmarkRecursively(reinterpret_cast<Object**>(&map_p), unmark_visitor); |
6221 | 6221 |
6222 obj->IterateBody(Map::cast(map_p)->instance_type(), | 6222 obj->IterateBody(Map::cast(map_p)->instance_type(), |
6223 obj->SizeFromMap(Map::cast(map_p)), | 6223 obj->SizeFromMap(Map::cast(map_p)), |
6224 unmark_visitor); | 6224 unmark_visitor); |
6225 } | 6225 } |
6226 | 6226 |
6227 | 6227 |
6228 void PathTracer::ProcessResults() { | 6228 void PathTracer::ProcessResults() { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6583 isolate_->heap()->store_buffer()->Compact(); | 6583 isolate_->heap()->store_buffer()->Compact(); |
6584 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6584 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
6585 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6585 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
6586 next = chunk->next_chunk(); | 6586 next = chunk->next_chunk(); |
6587 isolate_->memory_allocator()->Free(chunk); | 6587 isolate_->memory_allocator()->Free(chunk); |
6588 } | 6588 } |
6589 chunks_queued_for_free_ = NULL; | 6589 chunks_queued_for_free_ = NULL; |
6590 } | 6590 } |
6591 | 6591 |
6592 } } // namespace v8::internal | 6592 } } // namespace v8::internal |
OLD | NEW |