OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2301 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, | 2301 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, |
2302 int instance_size) { | 2302 int instance_size) { |
2303 Object* result; | 2303 Object* result; |
2304 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); | 2304 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
2305 if (!allocation.To(&result)) return allocation; | 2305 if (!allocation.To(&result)) return allocation; |
2306 | 2306 |
2307 // Map::cast cannot be used due to uninitialized map field. | 2307 // Map::cast cannot be used due to uninitialized map field. |
2308 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); | 2308 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); |
2309 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); | 2309 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); |
2310 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); | 2310 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); |
| 2311 // Initialize to only containing tagged fields. |
2311 reinterpret_cast<Map*>(result)->set_visitor_id( | 2312 reinterpret_cast<Map*>(result)->set_visitor_id( |
2312 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2313 StaticVisitorBase::GetVisitorId(instance_type, instance_size, false)); |
| 2314 if (FLAG_unbox_double_fields) { |
| 2315 reinterpret_cast<Map*>(result) |
| 2316 ->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2317 } |
2313 reinterpret_cast<Map*>(result)->set_inobject_properties(0); | 2318 reinterpret_cast<Map*>(result)->set_inobject_properties(0); |
2314 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); | 2319 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); |
2315 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); | 2320 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); |
2316 reinterpret_cast<Map*>(result)->set_bit_field(0); | 2321 reinterpret_cast<Map*>(result)->set_bit_field(0); |
2317 reinterpret_cast<Map*>(result)->set_bit_field2(0); | 2322 reinterpret_cast<Map*>(result)->set_bit_field2(0); |
2318 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | | 2323 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | |
2319 Map::OwnsDescriptors::encode(true); | 2324 Map::OwnsDescriptors::encode(true); |
2320 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); | 2325 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); |
2321 return result; | 2326 return result; |
2322 } | 2327 } |
2323 | 2328 |
2324 | 2329 |
2325 AllocationResult Heap::AllocateMap(InstanceType instance_type, | 2330 AllocationResult Heap::AllocateMap(InstanceType instance_type, |
2326 int instance_size, | 2331 int instance_size, |
2327 ElementsKind elements_kind) { | 2332 ElementsKind elements_kind) { |
2328 HeapObject* result; | 2333 HeapObject* result; |
2329 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); | 2334 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
2330 if (!allocation.To(&result)) return allocation; | 2335 if (!allocation.To(&result)) return allocation; |
2331 | 2336 |
2332 result->set_map_no_write_barrier(meta_map()); | 2337 result->set_map_no_write_barrier(meta_map()); |
2333 Map* map = Map::cast(result); | 2338 Map* map = Map::cast(result); |
2334 map->set_instance_type(instance_type); | 2339 map->set_instance_type(instance_type); |
2335 map->set_visitor_id( | |
2336 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | |
2337 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); | 2340 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); |
2338 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); | 2341 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); |
2339 map->set_instance_size(instance_size); | 2342 map->set_instance_size(instance_size); |
2340 map->set_inobject_properties(0); | 2343 map->set_inobject_properties(0); |
2341 map->set_pre_allocated_property_fields(0); | 2344 map->set_pre_allocated_property_fields(0); |
2342 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); | 2345 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); |
2343 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2346 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
2344 SKIP_WRITE_BARRIER); | 2347 SKIP_WRITE_BARRIER); |
2345 map->init_back_pointer(undefined_value()); | 2348 map->init_back_pointer(undefined_value()); |
2346 map->set_unused_property_fields(0); | 2349 map->set_unused_property_fields(0); |
2347 map->set_instance_descriptors(empty_descriptor_array()); | 2350 map->set_instance_descriptors(empty_descriptor_array()); |
| 2351 if (FLAG_unbox_double_fields) { |
| 2352 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2353 } |
| 2354 // Must be called only after |instance_type|, |instance_size| and |
| 2355 // |layout_descriptor| are set. |
| 2356 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); |
2348 map->set_bit_field(0); | 2357 map->set_bit_field(0); |
2349 map->set_bit_field2(1 << Map::kIsExtensible); | 2358 map->set_bit_field2(1 << Map::kIsExtensible); |
2350 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | | 2359 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | |
2351 Map::OwnsDescriptors::encode(true); | 2360 Map::OwnsDescriptors::encode(true); |
2352 map->set_bit_field3(bit_field3); | 2361 map->set_bit_field3(bit_field3); |
2353 map->set_elements_kind(elements_kind); | 2362 map->set_elements_kind(elements_kind); |
2354 | 2363 |
2355 return map; | 2364 return map; |
2356 } | 2365 } |
2357 | 2366 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 AllocationResult allocation = AllocateEmptyConstantPoolArray(); | 2473 AllocationResult allocation = AllocateEmptyConstantPoolArray(); |
2465 if (!allocation.To(&obj)) return false; | 2474 if (!allocation.To(&obj)) return false; |
2466 } | 2475 } |
2467 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); | 2476 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); |
2468 | 2477 |
2469 // Fix the instance_descriptors for the existing maps. | 2478 // Fix the instance_descriptors for the existing maps. |
2470 meta_map()->set_code_cache(empty_fixed_array()); | 2479 meta_map()->set_code_cache(empty_fixed_array()); |
2471 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2480 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2472 meta_map()->init_back_pointer(undefined_value()); | 2481 meta_map()->init_back_pointer(undefined_value()); |
2473 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2482 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2483 if (FLAG_unbox_double_fields) { |
| 2484 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2485 } |
2474 | 2486 |
2475 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2487 fixed_array_map()->set_code_cache(empty_fixed_array()); |
2476 fixed_array_map()->set_dependent_code( | 2488 fixed_array_map()->set_dependent_code( |
2477 DependentCode::cast(empty_fixed_array())); | 2489 DependentCode::cast(empty_fixed_array())); |
2478 fixed_array_map()->init_back_pointer(undefined_value()); | 2490 fixed_array_map()->init_back_pointer(undefined_value()); |
2479 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2491 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2492 if (FLAG_unbox_double_fields) { |
| 2493 fixed_array_map()->set_layout_descriptor( |
| 2494 LayoutDescriptor::FastPointerLayout()); |
| 2495 } |
2480 | 2496 |
2481 undefined_map()->set_code_cache(empty_fixed_array()); | 2497 undefined_map()->set_code_cache(empty_fixed_array()); |
2482 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2498 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2483 undefined_map()->init_back_pointer(undefined_value()); | 2499 undefined_map()->init_back_pointer(undefined_value()); |
2484 undefined_map()->set_instance_descriptors(empty_descriptor_array()); | 2500 undefined_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2501 if (FLAG_unbox_double_fields) { |
| 2502 undefined_map()->set_layout_descriptor( |
| 2503 LayoutDescriptor::FastPointerLayout()); |
| 2504 } |
2485 | 2505 |
2486 null_map()->set_code_cache(empty_fixed_array()); | 2506 null_map()->set_code_cache(empty_fixed_array()); |
2487 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2507 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2488 null_map()->init_back_pointer(undefined_value()); | 2508 null_map()->init_back_pointer(undefined_value()); |
2489 null_map()->set_instance_descriptors(empty_descriptor_array()); | 2509 null_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2510 if (FLAG_unbox_double_fields) { |
| 2511 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2512 } |
2490 | 2513 |
2491 constant_pool_array_map()->set_code_cache(empty_fixed_array()); | 2514 constant_pool_array_map()->set_code_cache(empty_fixed_array()); |
2492 constant_pool_array_map()->set_dependent_code( | 2515 constant_pool_array_map()->set_dependent_code( |
2493 DependentCode::cast(empty_fixed_array())); | 2516 DependentCode::cast(empty_fixed_array())); |
2494 constant_pool_array_map()->init_back_pointer(undefined_value()); | 2517 constant_pool_array_map()->init_back_pointer(undefined_value()); |
2495 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2518 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2519 if (FLAG_unbox_double_fields) { |
| 2520 constant_pool_array_map()->set_layout_descriptor( |
| 2521 LayoutDescriptor::FastPointerLayout()); |
| 2522 } |
2496 | 2523 |
2497 // Fix prototype object for existing maps. | 2524 // Fix prototype object for existing maps. |
2498 meta_map()->set_prototype(null_value()); | 2525 meta_map()->set_prototype(null_value()); |
2499 meta_map()->set_constructor(null_value()); | 2526 meta_map()->set_constructor(null_value()); |
2500 | 2527 |
2501 fixed_array_map()->set_prototype(null_value()); | 2528 fixed_array_map()->set_prototype(null_value()); |
2502 fixed_array_map()->set_constructor(null_value()); | 2529 fixed_array_map()->set_constructor(null_value()); |
2503 | 2530 |
2504 undefined_map()->set_prototype(null_value()); | 2531 undefined_map()->set_prototype(null_value()); |
2505 undefined_map()->set_constructor(null_value()); | 2532 undefined_map()->set_constructor(null_value()); |
(...skipping 3760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6266 static_cast<int>(object_sizes_last_time_[index])); | 6293 static_cast<int>(object_sizes_last_time_[index])); |
6267 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6294 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6268 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6295 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6269 | 6296 |
6270 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6297 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6271 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6298 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6272 ClearObjectStats(); | 6299 ClearObjectStats(); |
6273 } | 6300 } |
6274 } | 6301 } |
6275 } // namespace v8::internal | 6302 } // namespace v8::internal |
OLD | NEW |