Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/heap/heap.cc

Issue 950283002: Move Maps' back pointers from "transitions" to "constructor" field (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix stupidity on arm64 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 int instance_size, 2457 int instance_size,
2458 ElementsKind elements_kind) { 2458 ElementsKind elements_kind) {
2459 HeapObject* result; 2459 HeapObject* result;
2460 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); 2460 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE);
2461 if (!allocation.To(&result)) return allocation; 2461 if (!allocation.To(&result)) return allocation;
2462 2462
2463 result->set_map_no_write_barrier(meta_map()); 2463 result->set_map_no_write_barrier(meta_map());
2464 Map* map = Map::cast(result); 2464 Map* map = Map::cast(result);
2465 map->set_instance_type(instance_type); 2465 map->set_instance_type(instance_type);
2466 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); 2466 map->set_prototype(null_value(), SKIP_WRITE_BARRIER);
2467 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); 2467 map->set_constructor_or_backpointer(null_value(), SKIP_WRITE_BARRIER);
2468 map->set_instance_size(instance_size); 2468 map->set_instance_size(instance_size);
2469 map->set_inobject_properties(0); 2469 map->set_inobject_properties(0);
2470 map->set_pre_allocated_property_fields(0); 2470 map->set_pre_allocated_property_fields(0);
2471 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); 2471 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER);
2472 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2472 map->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2473 SKIP_WRITE_BARRIER); 2473 SKIP_WRITE_BARRIER);
2474 map->init_back_pointer(undefined_value()); 2474 map->init_transitions(undefined_value());
2475 map->set_unused_property_fields(0); 2475 map->set_unused_property_fields(0);
2476 map->set_instance_descriptors(empty_descriptor_array()); 2476 map->set_instance_descriptors(empty_descriptor_array());
2477 if (FLAG_unbox_double_fields) { 2477 if (FLAG_unbox_double_fields) {
2478 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2478 map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2479 } 2479 }
2480 // Must be called only after |instance_type|, |instance_size| and 2480 // Must be called only after |instance_type|, |instance_size| and
2481 // |layout_descriptor| are set. 2481 // |layout_descriptor| are set.
2482 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); 2482 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map));
2483 map->set_bit_field(0); 2483 map->set_bit_field(0);
2484 map->set_bit_field2(1 << Map::kIsExtensible); 2484 map->set_bit_field2(1 << Map::kIsExtensible);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 // Allocate the constant pool array. 2598 // Allocate the constant pool array.
2599 { 2599 {
2600 AllocationResult allocation = AllocateEmptyConstantPoolArray(); 2600 AllocationResult allocation = AllocateEmptyConstantPoolArray();
2601 if (!allocation.To(&obj)) return false; 2601 if (!allocation.To(&obj)) return false;
2602 } 2602 }
2603 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); 2603 set_empty_constant_pool_array(ConstantPoolArray::cast(obj));
2604 2604
2605 // Fix the instance_descriptors for the existing maps. 2605 // Fix the instance_descriptors for the existing maps.
2606 meta_map()->set_code_cache(empty_fixed_array()); 2606 meta_map()->set_code_cache(empty_fixed_array());
2607 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); 2607 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
2608 meta_map()->init_back_pointer(undefined_value()); 2608 meta_map()->init_transitions(undefined_value());
2609 meta_map()->set_instance_descriptors(empty_descriptor_array()); 2609 meta_map()->set_instance_descriptors(empty_descriptor_array());
2610 if (FLAG_unbox_double_fields) { 2610 if (FLAG_unbox_double_fields) {
2611 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2611 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2612 } 2612 }
2613 2613
2614 fixed_array_map()->set_code_cache(empty_fixed_array()); 2614 fixed_array_map()->set_code_cache(empty_fixed_array());
2615 fixed_array_map()->set_dependent_code( 2615 fixed_array_map()->set_dependent_code(
2616 DependentCode::cast(empty_fixed_array())); 2616 DependentCode::cast(empty_fixed_array()));
2617 fixed_array_map()->init_back_pointer(undefined_value()); 2617 fixed_array_map()->init_transitions(undefined_value());
2618 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); 2618 fixed_array_map()->set_instance_descriptors(empty_descriptor_array());
2619 if (FLAG_unbox_double_fields) { 2619 if (FLAG_unbox_double_fields) {
2620 fixed_array_map()->set_layout_descriptor( 2620 fixed_array_map()->set_layout_descriptor(
2621 LayoutDescriptor::FastPointerLayout()); 2621 LayoutDescriptor::FastPointerLayout());
2622 } 2622 }
2623 2623
2624 undefined_map()->set_code_cache(empty_fixed_array()); 2624 undefined_map()->set_code_cache(empty_fixed_array());
2625 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); 2625 undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
2626 undefined_map()->init_back_pointer(undefined_value()); 2626 undefined_map()->init_transitions(undefined_value());
2627 undefined_map()->set_instance_descriptors(empty_descriptor_array()); 2627 undefined_map()->set_instance_descriptors(empty_descriptor_array());
2628 if (FLAG_unbox_double_fields) { 2628 if (FLAG_unbox_double_fields) {
2629 undefined_map()->set_layout_descriptor( 2629 undefined_map()->set_layout_descriptor(
2630 LayoutDescriptor::FastPointerLayout()); 2630 LayoutDescriptor::FastPointerLayout());
2631 } 2631 }
2632 2632
2633 null_map()->set_code_cache(empty_fixed_array()); 2633 null_map()->set_code_cache(empty_fixed_array());
2634 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); 2634 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
2635 null_map()->init_back_pointer(undefined_value()); 2635 null_map()->init_transitions(undefined_value());
2636 null_map()->set_instance_descriptors(empty_descriptor_array()); 2636 null_map()->set_instance_descriptors(empty_descriptor_array());
2637 if (FLAG_unbox_double_fields) { 2637 if (FLAG_unbox_double_fields) {
2638 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2638 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2639 } 2639 }
2640 2640
2641 constant_pool_array_map()->set_code_cache(empty_fixed_array()); 2641 constant_pool_array_map()->set_code_cache(empty_fixed_array());
2642 constant_pool_array_map()->set_dependent_code( 2642 constant_pool_array_map()->set_dependent_code(
2643 DependentCode::cast(empty_fixed_array())); 2643 DependentCode::cast(empty_fixed_array()));
2644 constant_pool_array_map()->init_back_pointer(undefined_value()); 2644 constant_pool_array_map()->init_transitions(undefined_value());
2645 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); 2645 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array());
2646 if (FLAG_unbox_double_fields) { 2646 if (FLAG_unbox_double_fields) {
2647 constant_pool_array_map()->set_layout_descriptor( 2647 constant_pool_array_map()->set_layout_descriptor(
2648 LayoutDescriptor::FastPointerLayout()); 2648 LayoutDescriptor::FastPointerLayout());
2649 } 2649 }
2650 2650
2651 // Fix prototype object for existing maps. 2651 // Fix prototype object for existing maps.
2652 meta_map()->set_prototype(null_value()); 2652 meta_map()->set_prototype(null_value());
2653 meta_map()->set_constructor(null_value()); 2653 meta_map()->set_constructor_or_backpointer(null_value());
2654 2654
2655 fixed_array_map()->set_prototype(null_value()); 2655 fixed_array_map()->set_prototype(null_value());
2656 fixed_array_map()->set_constructor(null_value()); 2656 fixed_array_map()->set_constructor_or_backpointer(null_value());
2657 2657
2658 undefined_map()->set_prototype(null_value()); 2658 undefined_map()->set_prototype(null_value());
2659 undefined_map()->set_constructor(null_value()); 2659 undefined_map()->set_constructor_or_backpointer(null_value());
2660 2660
2661 null_map()->set_prototype(null_value()); 2661 null_map()->set_prototype(null_value());
2662 null_map()->set_constructor(null_value()); 2662 null_map()->set_constructor_or_backpointer(null_value());
2663 2663
2664 constant_pool_array_map()->set_prototype(null_value()); 2664 constant_pool_array_map()->set_prototype(null_value());
2665 constant_pool_array_map()->set_constructor(null_value()); 2665 constant_pool_array_map()->set_constructor_or_backpointer(null_value());
2666 2666
2667 { // Map allocation 2667 { // Map allocation
2668 #define ALLOCATE_MAP(instance_type, size, field_name) \ 2668 #define ALLOCATE_MAP(instance_type, size, field_name) \
2669 { \ 2669 { \
2670 Map* map; \ 2670 Map* map; \
2671 if (!AllocateMap((instance_type), size).To(&map)) return false; \ 2671 if (!AllocateMap((instance_type), size).To(&map)) return false; \
2672 set_##field_name##_map(map); \ 2672 set_##field_name##_map(map); \
2673 } 2673 }
2674 2674
2675 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ 2675 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3842 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object 3842 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object
3843 // verification code has to cope with (temporarily) invalid objects. See 3843 // verification code has to cope with (temporarily) invalid objects. See
3844 // for example, JSArray::JSArrayVerify). 3844 // for example, JSArray::JSArrayVerify).
3845 Object* filler; 3845 Object* filler;
3846 // We cannot always fill with one_pointer_filler_map because objects 3846 // We cannot always fill with one_pointer_filler_map because objects
3847 // created from API functions expect their internal fields to be initialized 3847 // created from API functions expect their internal fields to be initialized
3848 // with undefined_value. 3848 // with undefined_value.
3849 // Pre-allocated fields need to be initialized with undefined_value as well 3849 // Pre-allocated fields need to be initialized with undefined_value as well
3850 // so that object accesses before the constructor completes (e.g. in the 3850 // so that object accesses before the constructor completes (e.g. in the
3851 // debugger) will not cause a crash. 3851 // debugger) will not cause a crash.
3852 if (map->constructor()->IsJSFunction() && 3852 Object* constructor = map->GetConstructor();
3853 JSFunction::cast(map->constructor()) 3853 if (constructor->IsJSFunction() &&
3854 ->IsInobjectSlackTrackingInProgress()) { 3854 JSFunction::cast(constructor)->IsInobjectSlackTrackingInProgress()) {
3855 // We might want to shrink the object later. 3855 // We might want to shrink the object later.
3856 DCHECK(obj->GetInternalFieldCount() == 0); 3856 DCHECK(obj->GetInternalFieldCount() == 0);
3857 filler = Heap::one_pointer_filler_map(); 3857 filler = Heap::one_pointer_filler_map();
3858 } else { 3858 } else {
3859 filler = Heap::undefined_value(); 3859 filler = Heap::undefined_value();
3860 } 3860 }
3861 obj->InitializeBody(map, Heap::undefined_value(), filler); 3861 obj->InitializeBody(map, Heap::undefined_value(), filler);
3862 } 3862 }
3863 3863
3864 3864
(...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after
6522 static_cast<int>(object_sizes_last_time_[index])); 6522 static_cast<int>(object_sizes_last_time_[index]));
6523 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6523 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6524 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6524 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6525 6525
6526 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6526 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6527 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6527 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6528 ClearObjectStats(); 6528 ClearObjectStats();
6529 } 6529 }
6530 } 6530 }
6531 } // namespace v8::internal 6531 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698