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

Side by Side Diff: src/objects.cc

Issue 1276533003: [runtime] Store constructor function index on primitive maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm failures Created 5 years, 4 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/objects.h ('k') | src/objects-debug.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 return HeapType::Any(isolate); 67 return HeapType::Any(isolate);
68 } 68 }
69 69
70 70
71 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, 71 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
72 Handle<Object> object, 72 Handle<Object> object,
73 Handle<Context> native_context) { 73 Handle<Context> native_context) {
74 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); 74 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
75 Handle<JSFunction> constructor; 75 Handle<JSFunction> constructor;
76 if (object->IsNumber()) { 76 if (object->IsSmi()) {
77 constructor = handle(native_context->number_function(), isolate); 77 constructor = handle(native_context->number_function(), isolate);
78 } else if (object->IsBoolean()) { 78 } else {
79 constructor = handle(native_context->boolean_function(), isolate); 79 int constructor_function_index =
80 } else if (object->IsString()) { 80 Handle<HeapObject>::cast(object)->map()->GetConstructorFunctionIndex();
81 constructor = handle(native_context->string_function(), isolate); 81 if (constructor_function_index == Map::kNoConstructorFunctionIndex) {
82 } else if (object->IsSymbol()) { 82 return MaybeHandle<JSReceiver>();
83 constructor = handle(native_context->symbol_function(), isolate);
84 } else if (object->IsSimd128Value()) {
85 if (object->IsFloat32x4()) {
86 constructor = handle(native_context->float32x4_function(), isolate);
87 } else if (object->IsInt32x4()) {
88 constructor = handle(native_context->int32x4_function(), isolate);
89 } else if (object->IsBool32x4()) {
90 constructor = handle(native_context->bool32x4_function(), isolate);
91 } else if (object->IsInt16x8()) {
92 constructor = handle(native_context->int16x8_function(), isolate);
93 } else if (object->IsBool16x8()) {
94 constructor = handle(native_context->bool16x8_function(), isolate);
95 } else if (object->IsInt8x16()) {
96 constructor = handle(native_context->int8x16_function(), isolate);
97 } else if (object->IsBool8x16()) {
98 constructor = handle(native_context->bool8x16_function(), isolate);
99 } else {
100 UNREACHABLE();
101 } 83 }
102 } else { 84 constructor = handle(
103 return MaybeHandle<JSReceiver>(); 85 JSFunction::cast(native_context->get(constructor_function_index)),
86 isolate);
104 } 87 }
105 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); 88 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
106 Handle<JSValue>::cast(result)->set_value(*object); 89 Handle<JSValue>::cast(result)->set_value(*object);
107 return result; 90 return result;
108 } 91 }
109 92
110 93
111 bool Object::BooleanValue() { 94 bool Object::BooleanValue() {
112 if (IsBoolean()) return IsTrue(); 95 if (IsBoolean()) return IsTrue();
113 if (IsSmi()) return Smi::cast(this)->value() != 0; 96 if (IsSmi()) return Smi::cast(this)->value() != 0;
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 details = details.set_index(enumeration_index); 595 details = details.set_index(enumeration_index);
613 property_dictionary->SetEntry(entry, name, value, details); 596 property_dictionary->SetEntry(entry, name, value, details);
614 } 597 }
615 } 598 }
616 } 599 }
617 600
618 601
619 Map* Object::GetRootMap(Isolate* isolate) { 602 Map* Object::GetRootMap(Isolate* isolate) {
620 DisallowHeapAllocation no_alloc; 603 DisallowHeapAllocation no_alloc;
621 if (IsSmi()) { 604 if (IsSmi()) {
622 Context* context = isolate->context()->native_context(); 605 Context* native_context = isolate->context()->native_context();
623 return context->number_function()->initial_map(); 606 return native_context->number_function()->initial_map();
624 } 607 }
625 608
626 HeapObject* heap_object = HeapObject::cast(this);
627
628 // The object is either a number, a string, a symbol, a boolean, a SIMD value, 609 // The object is either a number, a string, a symbol, a boolean, a SIMD value,
629 // a real JS object, or a Harmony proxy. 610 // a real JS object, or a Harmony proxy.
611 HeapObject* heap_object = HeapObject::cast(this);
630 if (heap_object->IsJSReceiver()) { 612 if (heap_object->IsJSReceiver()) {
631 return heap_object->map(); 613 return heap_object->map();
632 } 614 }
633 Context* context = isolate->context()->native_context(); 615 int constructor_function_index =
634 616 heap_object->map()->GetConstructorFunctionIndex();
635 if (heap_object->IsHeapNumber()) { 617 if (constructor_function_index != Map::kNoConstructorFunctionIndex) {
636 return context->number_function()->initial_map(); 618 Context* native_context = isolate->context()->native_context();
637 } 619 JSFunction* constructor_function =
638 if (heap_object->IsString()) { 620 JSFunction::cast(native_context->get(constructor_function_index));
639 return context->string_function()->initial_map(); 621 return constructor_function->initial_map();
640 }
641 if (heap_object->IsSymbol()) {
642 return context->symbol_function()->initial_map();
643 }
644 if (heap_object->IsBoolean()) {
645 return context->boolean_function()->initial_map();
646 }
647 if (heap_object->IsSimd128Value()) {
648 if (heap_object->IsFloat32x4()) {
649 return context->float32x4_function()->initial_map();
650 } else if (heap_object->IsInt32x4()) {
651 return context->int32x4_function()->initial_map();
652 } else if (heap_object->IsBool32x4()) {
653 return context->bool32x4_function()->initial_map();
654 } else if (heap_object->IsInt16x8()) {
655 return context->int16x8_function()->initial_map();
656 } else if (heap_object->IsBool16x8()) {
657 return context->bool16x8_function()->initial_map();
658 } else if (heap_object->IsInt8x16()) {
659 return context->int8x16_function()->initial_map();
660 } else if (heap_object->IsBool8x16()) {
661 return context->bool8x16_function()->initial_map();
662 } else {
663 UNREACHABLE();
664 }
665 } 622 }
666 return isolate->heap()->null_value()->map(); 623 return isolate->heap()->null_value()->map();
667 } 624 }
668 625
669 626
670 Object* Object::GetHash() { 627 Object* Object::GetHash() {
671 Object* hash = GetSimpleHash(); 628 Object* hash = GetSimpleHash();
672 if (hash->IsSmi()) return hash; 629 if (hash->IsSmi()) return hash;
673 630
674 DCHECK(IsJSReceiver()); 631 DCHECK(IsJSReceiver());
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 int limit = NumberOfOwnDescriptors(); 1814 int limit = NumberOfOwnDescriptors();
1858 for (int i = 0; i < limit; i++) { 1815 for (int i = 0; i < limit; i++) {
1859 if (new_desc->GetDetails(i).representation().IsDouble() != 1816 if (new_desc->GetDetails(i).representation().IsDouble() !=
1860 old_desc->GetDetails(i).representation().IsDouble()) { 1817 old_desc->GetDetails(i).representation().IsDouble()) {
1861 return true; 1818 return true;
1862 } 1819 }
1863 } 1820 }
1864 1821
1865 // If no fields were added, and no inobject properties were removed, setting 1822 // If no fields were added, and no inobject properties were removed, setting
1866 // the map is sufficient. 1823 // the map is sufficient.
1867 if (target_inobject == inobject_properties()) return false; 1824 if (target_inobject == GetInObjectProperties()) return false;
1868 // In-object slack tracking may have reduced the object size of the new map. 1825 // In-object slack tracking may have reduced the object size of the new map.
1869 // In that case, succeed if all existing fields were inobject, and they still 1826 // In that case, succeed if all existing fields were inobject, and they still
1870 // fit within the new inobject size. 1827 // fit within the new inobject size.
1871 DCHECK(target_inobject < inobject_properties()); 1828 DCHECK(target_inobject < GetInObjectProperties());
1872 if (target_number_of_fields <= target_inobject) { 1829 if (target_number_of_fields <= target_inobject) {
1873 DCHECK(target_number_of_fields + target_unused == target_inobject); 1830 DCHECK(target_number_of_fields + target_unused == target_inobject);
1874 return false; 1831 return false;
1875 } 1832 }
1876 // Otherwise, properties will need to be moved to the backing store. 1833 // Otherwise, properties will need to be moved to the backing store.
1877 return true; 1834 return true;
1878 } 1835 }
1879 1836
1880 1837
1881 static void UpdatePrototypeUserRegistration(Handle<Map> old_map, 1838 static void UpdatePrototypeUserRegistration(Handle<Map> old_map,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 // frees inobject properties that moved to the backing store. 1925 // frees inobject properties that moved to the backing store.
1969 // * If there are properties left in the backing store, trim of the space used 1926 // * If there are properties left in the backing store, trim of the space used
1970 // to temporarily store the inobject properties. 1927 // to temporarily store the inobject properties.
1971 // * If there are properties left in the backing store, install the backing 1928 // * If there are properties left in the backing store, install the backing
1972 // store. 1929 // store.
1973 void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) { 1930 void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
1974 Isolate* isolate = object->GetIsolate(); 1931 Isolate* isolate = object->GetIsolate();
1975 Handle<Map> old_map(object->map()); 1932 Handle<Map> old_map(object->map());
1976 int old_number_of_fields; 1933 int old_number_of_fields;
1977 int number_of_fields = new_map->NumberOfFields(); 1934 int number_of_fields = new_map->NumberOfFields();
1978 int inobject = new_map->inobject_properties(); 1935 int inobject = new_map->GetInObjectProperties();
1979 int unused = new_map->unused_property_fields(); 1936 int unused = new_map->unused_property_fields();
1980 1937
1981 // Nothing to do if no functions were converted to fields and no smis were 1938 // Nothing to do if no functions were converted to fields and no smis were
1982 // converted to doubles. 1939 // converted to doubles.
1983 if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject, 1940 if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject,
1984 unused, &old_number_of_fields)) { 1941 unused, &old_number_of_fields)) {
1985 object->synchronized_set_map(*new_map); 1942 object->synchronized_set_map(*new_map);
1986 return; 1943 return;
1987 } 1944 }
1988 1945
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4175 Object); 4132 Object);
4176 } 4133 }
4177 trap = Handle<Object>(derived); 4134 trap = Handle<Object>(derived);
4178 } 4135 }
4179 4136
4180 return Execution::Call(isolate, trap, handler, argc, argv); 4137 return Execution::Call(isolate, trap, handler, argc, argv);
4181 } 4138 }
4182 4139
4183 4140
4184 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { 4141 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
4185 DCHECK(object->map()->inobject_properties() == map->inobject_properties()); 4142 DCHECK(object->map()->GetInObjectProperties() ==
4143 map->GetInObjectProperties());
4186 ElementsKind obj_kind = object->map()->elements_kind(); 4144 ElementsKind obj_kind = object->map()->elements_kind();
4187 ElementsKind map_kind = map->elements_kind(); 4145 ElementsKind map_kind = map->elements_kind();
4188 if (map_kind != obj_kind) { 4146 if (map_kind != obj_kind) {
4189 ElementsKind to_kind = map_kind; 4147 ElementsKind to_kind = map_kind;
4190 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || 4148 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) ||
4191 IsDictionaryElementsKind(obj_kind)) { 4149 IsDictionaryElementsKind(obj_kind)) {
4192 to_kind = obj_kind; 4150 to_kind = obj_kind;
4193 } 4151 }
4194 if (IsDictionaryElementsKind(to_kind)) { 4152 if (IsDictionaryElementsKind(to_kind)) {
4195 NormalizeElements(object); 4153 NormalizeElements(object);
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
4687 } 4645 }
4688 4646
4689 // We are storing the new map using release store after creating a filler for 4647 // We are storing the new map using release store after creating a filler for
4690 // the left-over space to avoid races with the sweeper thread. 4648 // the left-over space to avoid races with the sweeper thread.
4691 object->synchronized_set_map(*new_map); 4649 object->synchronized_set_map(*new_map);
4692 4650
4693 object->set_properties(*dictionary); 4651 object->set_properties(*dictionary);
4694 4652
4695 // Ensure that in-object space of slow-mode object does not contain random 4653 // Ensure that in-object space of slow-mode object does not contain random
4696 // garbage. 4654 // garbage.
4697 int inobject_properties = new_map->inobject_properties(); 4655 int inobject_properties = new_map->GetInObjectProperties();
4698 for (int i = 0; i < inobject_properties; i++) { 4656 for (int i = 0; i < inobject_properties; i++) {
4699 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i); 4657 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i);
4700 object->RawFastPropertyAtPut(index, Smi::FromInt(0)); 4658 object->RawFastPropertyAtPut(index, Smi::FromInt(0));
4701 } 4659 }
4702 4660
4703 isolate->counters()->props_to_dictionary()->Increment(); 4661 isolate->counters()->props_to_dictionary()->Increment();
4704 4662
4705 #ifdef DEBUG 4663 #ifdef DEBUG
4706 if (FLAG_trace_normalization) { 4664 if (FLAG_trace_normalization) {
4707 OFStream os(stdout); 4665 OFStream os(stdout);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4744 4702
4745 Object* value = dictionary->ValueAt(index); 4703 Object* value = dictionary->ValueAt(index);
4746 PropertyType type = dictionary->DetailsAt(index).type(); 4704 PropertyType type = dictionary->DetailsAt(index).type();
4747 if (type == DATA && !value->IsJSFunction()) { 4705 if (type == DATA && !value->IsJSFunction()) {
4748 number_of_fields += 1; 4706 number_of_fields += 1;
4749 } 4707 }
4750 } 4708 }
4751 4709
4752 Handle<Map> old_map(object->map(), isolate); 4710 Handle<Map> old_map(object->map(), isolate);
4753 4711
4754 int inobject_props = old_map->inobject_properties(); 4712 int inobject_props = old_map->GetInObjectProperties();
4755 4713
4756 // Allocate new map. 4714 // Allocate new map.
4757 Handle<Map> new_map = Map::CopyDropDescriptors(old_map); 4715 Handle<Map> new_map = Map::CopyDropDescriptors(old_map);
4758 new_map->set_dictionary_map(false); 4716 new_map->set_dictionary_map(false);
4759 4717
4760 UpdatePrototypeUserRegistration(old_map, new_map, isolate); 4718 UpdatePrototypeUserRegistration(old_map, new_map, isolate);
4761 4719
4762 #if TRACE_MAPS 4720 #if TRACE_MAPS
4763 if (FLAG_trace_maps) { 4721 if (FLAG_trace_maps) {
4764 PrintF("[TraceMaps: SlowToFast from= %p to= %p reason= %s ]\n", 4722 PrintF("[TraceMaps: SlowToFast from= %p to= %p reason= %s ]\n",
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
6632 } 6590 }
6633 fast_map->NotifyLeafMapLayoutChange(); 6591 fast_map->NotifyLeafMapLayoutChange();
6634 return new_map; 6592 return new_map;
6635 } 6593 }
6636 6594
6637 6595
6638 Handle<Map> Map::CopyNormalized(Handle<Map> map, 6596 Handle<Map> Map::CopyNormalized(Handle<Map> map,
6639 PropertyNormalizationMode mode) { 6597 PropertyNormalizationMode mode) {
6640 int new_instance_size = map->instance_size(); 6598 int new_instance_size = map->instance_size();
6641 if (mode == CLEAR_INOBJECT_PROPERTIES) { 6599 if (mode == CLEAR_INOBJECT_PROPERTIES) {
6642 new_instance_size -= map->inobject_properties() * kPointerSize; 6600 new_instance_size -= map->GetInObjectProperties() * kPointerSize;
6643 } 6601 }
6644 6602
6645 Handle<Map> result = RawCopy(map, new_instance_size); 6603 Handle<Map> result = RawCopy(map, new_instance_size);
6646 6604
6647 if (mode != CLEAR_INOBJECT_PROPERTIES) { 6605 if (mode != CLEAR_INOBJECT_PROPERTIES) {
6648 result->set_inobject_properties(map->inobject_properties()); 6606 result->SetInObjectProperties(map->GetInObjectProperties());
6649 } 6607 }
6650 6608
6651 result->set_dictionary_map(true); 6609 result->set_dictionary_map(true);
6652 result->set_migration_target(false); 6610 result->set_migration_target(false);
6653 6611
6654 #ifdef VERIFY_HEAP 6612 #ifdef VERIFY_HEAP
6655 if (FLAG_verify_heap) result->DictionaryMapVerify(); 6613 if (FLAG_verify_heap) result->DictionaryMapVerify();
6656 #endif 6614 #endif
6657 6615
6658 return result; 6616 return result;
6659 } 6617 }
6660 6618
6661 6619
6662 Handle<Map> Map::CopyDropDescriptors(Handle<Map> map) { 6620 Handle<Map> Map::CopyDropDescriptors(Handle<Map> map) {
6663 Handle<Map> result = RawCopy(map, map->instance_size()); 6621 Handle<Map> result = RawCopy(map, map->instance_size());
6664 6622
6665 // Please note instance_type and instance_size are set when allocated. 6623 // Please note instance_type and instance_size are set when allocated.
6666 result->set_inobject_properties(map->inobject_properties()); 6624 result->SetInObjectProperties(map->GetInObjectProperties());
6667 result->set_unused_property_fields(map->unused_property_fields()); 6625 result->set_unused_property_fields(map->unused_property_fields());
6668 6626
6669 result->ClearCodeCache(map->GetHeap()); 6627 result->ClearCodeCache(map->GetHeap());
6670 map->NotifyLeafMapLayoutChange(); 6628 map->NotifyLeafMapLayoutChange();
6671 return result; 6629 return result;
6672 } 6630 }
6673 6631
6674 6632
6675 Handle<Map> Map::ShareDescriptor(Handle<Map> map, 6633 Handle<Map> Map::ShareDescriptor(Handle<Map> map,
6676 Handle<DescriptorArray> descriptors, 6634 Handle<DescriptorArray> descriptors,
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
6968 (JSObject::kMaxInstanceSize - JSObject::kHeaderSize) >> kPointerSizeLog2; 6926 (JSObject::kMaxInstanceSize - JSObject::kHeaderSize) >> kPointerSizeLog2;
6969 6927
6970 if (inobject_properties > max_extra_properties) { 6928 if (inobject_properties > max_extra_properties) {
6971 inobject_properties = max_extra_properties; 6929 inobject_properties = max_extra_properties;
6972 } 6930 }
6973 6931
6974 int new_instance_size = 6932 int new_instance_size =
6975 JSObject::kHeaderSize + kPointerSize * inobject_properties; 6933 JSObject::kHeaderSize + kPointerSize * inobject_properties;
6976 6934
6977 // Adjust the map with the extra inobject properties. 6935 // Adjust the map with the extra inobject properties.
6978 copy->set_inobject_properties(inobject_properties); 6936 copy->SetInObjectProperties(inobject_properties);
6979 copy->set_unused_property_fields(inobject_properties); 6937 copy->set_unused_property_fields(inobject_properties);
6980 copy->set_instance_size(new_instance_size); 6938 copy->set_instance_size(new_instance_size);
6981 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); 6939 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
6982 return copy; 6940 return copy;
6983 } 6941 }
6984 6942
6985 6943
6986 Handle<Map> Map::CopyForPreventExtensions(Handle<Map> map, 6944 Handle<Map> Map::CopyForPreventExtensions(Handle<Map> map,
6987 PropertyAttributes attrs_to_add, 6945 PropertyAttributes attrs_to_add,
6988 Handle<Symbol> transition_marker, 6946 Handle<Symbol> transition_marker,
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
9362 } 9320 }
9363 9321
9364 9322
9365 bool Map::EquivalentToForTransition(Map* other) { 9323 bool Map::EquivalentToForTransition(Map* other) {
9366 return CheckEquivalent(this, other); 9324 return CheckEquivalent(this, other);
9367 } 9325 }
9368 9326
9369 9327
9370 bool Map::EquivalentToForNormalization(Map* other, 9328 bool Map::EquivalentToForNormalization(Map* other,
9371 PropertyNormalizationMode mode) { 9329 PropertyNormalizationMode mode) {
9372 int properties = mode == CLEAR_INOBJECT_PROPERTIES 9330 int properties =
9373 ? 0 : other->inobject_properties(); 9331 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties();
9374 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && 9332 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() &&
9375 inobject_properties() == properties; 9333 GetInObjectProperties() == properties;
9376 } 9334 }
9377 9335
9378 9336
9379 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { 9337 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) {
9380 // Iterate over all fields in the body but take care in dealing with 9338 // Iterate over all fields in the body but take care in dealing with
9381 // the code entry. 9339 // the code entry.
9382 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); 9340 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset);
9383 v->VisitCodeEntry(this->address() + kCodeEntryOffset); 9341 v->VisitCodeEntry(this->address() + kCodeEntryOffset);
9384 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); 9342 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size);
9385 } 9343 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
9623 static void GetMinInobjectSlack(Map* map, void* data) { 9581 static void GetMinInobjectSlack(Map* map, void* data) {
9624 int slack = map->unused_property_fields(); 9582 int slack = map->unused_property_fields();
9625 if (*reinterpret_cast<int*>(data) > slack) { 9583 if (*reinterpret_cast<int*>(data) > slack) {
9626 *reinterpret_cast<int*>(data) = slack; 9584 *reinterpret_cast<int*>(data) = slack;
9627 } 9585 }
9628 } 9586 }
9629 9587
9630 9588
9631 static void ShrinkInstanceSize(Map* map, void* data) { 9589 static void ShrinkInstanceSize(Map* map, void* data) {
9632 int slack = *reinterpret_cast<int*>(data); 9590 int slack = *reinterpret_cast<int*>(data);
9633 map->set_inobject_properties(map->inobject_properties() - slack); 9591 map->SetInObjectProperties(map->GetInObjectProperties() - slack);
9634 map->set_unused_property_fields(map->unused_property_fields() - slack); 9592 map->set_unused_property_fields(map->unused_property_fields() - slack);
9635 map->set_instance_size(map->instance_size() - slack * kPointerSize); 9593 map->set_instance_size(map->instance_size() - slack * kPointerSize);
9636 9594
9637 // Visitor id might depend on the instance size, recalculate it. 9595 // Visitor id might depend on the instance size, recalculate it.
9638 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); 9596 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map));
9639 } 9597 }
9640 9598
9641 9599
9642 void JSFunction::CompleteInobjectSlackTracking() { 9600 void JSFunction::CompleteInobjectSlackTracking() {
9643 DCHECK(has_initial_map()); 9601 DCHECK(has_initial_map());
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
10105 } 10063 }
10106 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); 10064 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size);
10107 10065
10108 // Fetch or allocate prototype. 10066 // Fetch or allocate prototype.
10109 Handle<Object> prototype; 10067 Handle<Object> prototype;
10110 if (function->has_instance_prototype()) { 10068 if (function->has_instance_prototype()) {
10111 prototype = handle(function->instance_prototype(), isolate); 10069 prototype = handle(function->instance_prototype(), isolate);
10112 } else { 10070 } else {
10113 prototype = isolate->factory()->NewFunctionPrototype(function); 10071 prototype = isolate->factory()->NewFunctionPrototype(function);
10114 } 10072 }
10115 map->set_inobject_properties(in_object_properties); 10073 map->SetInObjectProperties(in_object_properties);
10116 map->set_unused_property_fields(in_object_properties); 10074 map->set_unused_property_fields(in_object_properties);
10117 DCHECK(map->has_fast_object_elements()); 10075 DCHECK(map->has_fast_object_elements());
10118 10076
10119 // Finally link initial map and constructor function. 10077 // Finally link initial map and constructor function.
10120 JSFunction::SetInitialMap(function, map, Handle<JSReceiver>::cast(prototype)); 10078 JSFunction::SetInitialMap(function, map, Handle<JSReceiver>::cast(prototype));
10121 10079
10122 if (!function->shared()->is_generator()) { 10080 if (!function->shared()->is_generator()) {
10123 function->StartInobjectSlackTracking(); 10081 function->StartInobjectSlackTracking();
10124 } 10082 }
10125 } 10083 }
(...skipping 5738 matching lines...) Expand 10 before | Expand all | Expand 10 after
15864 if (cell->value() != *new_value) { 15822 if (cell->value() != *new_value) {
15865 cell->set_value(*new_value); 15823 cell->set_value(*new_value);
15866 Isolate* isolate = cell->GetIsolate(); 15824 Isolate* isolate = cell->GetIsolate();
15867 cell->dependent_code()->DeoptimizeDependentCodeGroup( 15825 cell->dependent_code()->DeoptimizeDependentCodeGroup(
15868 isolate, DependentCode::kPropertyCellChangedGroup); 15826 isolate, DependentCode::kPropertyCellChangedGroup);
15869 } 15827 }
15870 } 15828 }
15871 15829
15872 } // namespace internal 15830 } // namespace internal
15873 } // namespace v8 15831 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698