| 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 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, | 2288 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, |
| 2289 int instance_size) { | 2289 int instance_size) { |
| 2290 Object* result; | 2290 Object* result; |
| 2291 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); | 2291 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
| 2292 if (!allocation.To(&result)) return allocation; | 2292 if (!allocation.To(&result)) return allocation; |
| 2293 | 2293 |
| 2294 // Map::cast cannot be used due to uninitialized map field. | 2294 // Map::cast cannot be used due to uninitialized map field. |
| 2295 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); | 2295 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); |
| 2296 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); | 2296 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); |
| 2297 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); | 2297 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); |
| 2298 // Initialize to only containing tagged fields. |
| 2298 reinterpret_cast<Map*>(result)->set_visitor_id( | 2299 reinterpret_cast<Map*>(result)->set_visitor_id( |
| 2299 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2300 StaticVisitorBase::GetVisitorId(instance_type, instance_size, false)); |
| 2301 if (FLAG_unbox_double_fields) { |
| 2302 reinterpret_cast<Map*>(result) |
| 2303 ->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2304 } |
| 2300 reinterpret_cast<Map*>(result)->set_inobject_properties(0); | 2305 reinterpret_cast<Map*>(result)->set_inobject_properties(0); |
| 2301 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); | 2306 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); |
| 2302 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); | 2307 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); |
| 2303 reinterpret_cast<Map*>(result)->set_bit_field(0); | 2308 reinterpret_cast<Map*>(result)->set_bit_field(0); |
| 2304 reinterpret_cast<Map*>(result)->set_bit_field2(0); | 2309 reinterpret_cast<Map*>(result)->set_bit_field2(0); |
| 2305 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | | 2310 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | |
| 2306 Map::OwnsDescriptors::encode(true); | 2311 Map::OwnsDescriptors::encode(true); |
| 2307 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); | 2312 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); |
| 2308 return result; | 2313 return result; |
| 2309 } | 2314 } |
| 2310 | 2315 |
| 2311 | 2316 |
| 2312 AllocationResult Heap::AllocateMap(InstanceType instance_type, | 2317 AllocationResult Heap::AllocateMap(InstanceType instance_type, |
| 2313 int instance_size, | 2318 int instance_size, |
| 2314 ElementsKind elements_kind) { | 2319 ElementsKind elements_kind) { |
| 2315 HeapObject* result; | 2320 HeapObject* result; |
| 2316 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); | 2321 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
| 2317 if (!allocation.To(&result)) return allocation; | 2322 if (!allocation.To(&result)) return allocation; |
| 2318 | 2323 |
| 2319 result->set_map_no_write_barrier(meta_map()); | 2324 result->set_map_no_write_barrier(meta_map()); |
| 2320 Map* map = Map::cast(result); | 2325 Map* map = Map::cast(result); |
| 2321 map->set_instance_type(instance_type); | 2326 map->set_instance_type(instance_type); |
| 2322 map->set_visitor_id( | |
| 2323 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | |
| 2324 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); | 2327 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); |
| 2325 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); | 2328 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); |
| 2326 map->set_instance_size(instance_size); | 2329 map->set_instance_size(instance_size); |
| 2327 map->set_inobject_properties(0); | 2330 map->set_inobject_properties(0); |
| 2328 map->set_pre_allocated_property_fields(0); | 2331 map->set_pre_allocated_property_fields(0); |
| 2329 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); | 2332 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 2330 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2333 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
| 2331 SKIP_WRITE_BARRIER); | 2334 SKIP_WRITE_BARRIER); |
| 2332 map->init_back_pointer(undefined_value()); | 2335 map->init_back_pointer(undefined_value()); |
| 2333 map->set_unused_property_fields(0); | 2336 map->set_unused_property_fields(0); |
| 2334 map->set_instance_descriptors(empty_descriptor_array()); | 2337 map->set_instance_descriptors(empty_descriptor_array()); |
| 2338 if (FLAG_unbox_double_fields) { |
| 2339 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2340 } |
| 2341 // Must be called only after |instance_type|, |instance_size| and |
| 2342 // |layout_descriptor| are set. |
| 2343 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); |
| 2335 map->set_bit_field(0); | 2344 map->set_bit_field(0); |
| 2336 map->set_bit_field2(1 << Map::kIsExtensible); | 2345 map->set_bit_field2(1 << Map::kIsExtensible); |
| 2337 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | | 2346 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) | |
| 2338 Map::OwnsDescriptors::encode(true); | 2347 Map::OwnsDescriptors::encode(true); |
| 2339 map->set_bit_field3(bit_field3); | 2348 map->set_bit_field3(bit_field3); |
| 2340 map->set_elements_kind(elements_kind); | 2349 map->set_elements_kind(elements_kind); |
| 2341 | 2350 |
| 2342 return map; | 2351 return map; |
| 2343 } | 2352 } |
| 2344 | 2353 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 AllocationResult allocation = AllocateEmptyConstantPoolArray(); | 2460 AllocationResult allocation = AllocateEmptyConstantPoolArray(); |
| 2452 if (!allocation.To(&obj)) return false; | 2461 if (!allocation.To(&obj)) return false; |
| 2453 } | 2462 } |
| 2454 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); | 2463 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); |
| 2455 | 2464 |
| 2456 // Fix the instance_descriptors for the existing maps. | 2465 // Fix the instance_descriptors for the existing maps. |
| 2457 meta_map()->set_code_cache(empty_fixed_array()); | 2466 meta_map()->set_code_cache(empty_fixed_array()); |
| 2458 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2467 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2459 meta_map()->init_back_pointer(undefined_value()); | 2468 meta_map()->init_back_pointer(undefined_value()); |
| 2460 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2469 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2470 if (FLAG_unbox_double_fields) { |
| 2471 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2472 } |
| 2461 | 2473 |
| 2462 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2474 fixed_array_map()->set_code_cache(empty_fixed_array()); |
| 2463 fixed_array_map()->set_dependent_code( | 2475 fixed_array_map()->set_dependent_code( |
| 2464 DependentCode::cast(empty_fixed_array())); | 2476 DependentCode::cast(empty_fixed_array())); |
| 2465 fixed_array_map()->init_back_pointer(undefined_value()); | 2477 fixed_array_map()->init_back_pointer(undefined_value()); |
| 2466 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2478 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2479 if (FLAG_unbox_double_fields) { |
| 2480 fixed_array_map()->set_layout_descriptor( |
| 2481 LayoutDescriptor::FastPointerLayout()); |
| 2482 } |
| 2467 | 2483 |
| 2468 undefined_map()->set_code_cache(empty_fixed_array()); | 2484 undefined_map()->set_code_cache(empty_fixed_array()); |
| 2469 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2485 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2470 undefined_map()->init_back_pointer(undefined_value()); | 2486 undefined_map()->init_back_pointer(undefined_value()); |
| 2471 undefined_map()->set_instance_descriptors(empty_descriptor_array()); | 2487 undefined_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2488 if (FLAG_unbox_double_fields) { |
| 2489 undefined_map()->set_layout_descriptor( |
| 2490 LayoutDescriptor::FastPointerLayout()); |
| 2491 } |
| 2472 | 2492 |
| 2473 null_map()->set_code_cache(empty_fixed_array()); | 2493 null_map()->set_code_cache(empty_fixed_array()); |
| 2474 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2494 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2475 null_map()->init_back_pointer(undefined_value()); | 2495 null_map()->init_back_pointer(undefined_value()); |
| 2476 null_map()->set_instance_descriptors(empty_descriptor_array()); | 2496 null_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2497 if (FLAG_unbox_double_fields) { |
| 2498 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2499 } |
| 2477 | 2500 |
| 2478 constant_pool_array_map()->set_code_cache(empty_fixed_array()); | 2501 constant_pool_array_map()->set_code_cache(empty_fixed_array()); |
| 2479 constant_pool_array_map()->set_dependent_code( | 2502 constant_pool_array_map()->set_dependent_code( |
| 2480 DependentCode::cast(empty_fixed_array())); | 2503 DependentCode::cast(empty_fixed_array())); |
| 2481 constant_pool_array_map()->init_back_pointer(undefined_value()); | 2504 constant_pool_array_map()->init_back_pointer(undefined_value()); |
| 2482 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2505 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2506 if (FLAG_unbox_double_fields) { |
| 2507 constant_pool_array_map()->set_layout_descriptor( |
| 2508 LayoutDescriptor::FastPointerLayout()); |
| 2509 } |
| 2483 | 2510 |
| 2484 // Fix prototype object for existing maps. | 2511 // Fix prototype object for existing maps. |
| 2485 meta_map()->set_prototype(null_value()); | 2512 meta_map()->set_prototype(null_value()); |
| 2486 meta_map()->set_constructor(null_value()); | 2513 meta_map()->set_constructor(null_value()); |
| 2487 | 2514 |
| 2488 fixed_array_map()->set_prototype(null_value()); | 2515 fixed_array_map()->set_prototype(null_value()); |
| 2489 fixed_array_map()->set_constructor(null_value()); | 2516 fixed_array_map()->set_constructor(null_value()); |
| 2490 | 2517 |
| 2491 undefined_map()->set_prototype(null_value()); | 2518 undefined_map()->set_prototype(null_value()); |
| 2492 undefined_map()->set_constructor(null_value()); | 2519 undefined_map()->set_constructor(null_value()); |
| (...skipping 3759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6252 static_cast<int>(object_sizes_last_time_[index])); | 6279 static_cast<int>(object_sizes_last_time_[index])); |
| 6253 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6280 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6254 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6281 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6255 | 6282 |
| 6256 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6283 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6257 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6284 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6258 ClearObjectStats(); | 6285 ClearObjectStats(); |
| 6259 } | 6286 } |
| 6260 } | 6287 } |
| 6261 } // namespace v8::internal | 6288 } // namespace v8::internal |
| OLD | NEW |