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

Side by Side Diff: src/objects.cc

Issue 911713003: add transitions for global properties in ics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/objects.h ('k') | test/cctest/test-heap-profiler.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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry))); 1745 Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry)));
1746 PropertyCell::SetValueInferType(cell, value); 1746 PropertyCell::SetValueInferType(cell, value);
1747 // Assign an enumeration index to the property and update 1747 // Assign an enumeration index to the property and update
1748 // SetNextEnumerationIndex. 1748 // SetNextEnumerationIndex.
1749 int index = dict->NextEnumerationIndex(); 1749 int index = dict->NextEnumerationIndex();
1750 PropertyDetails details(attributes, DATA, index); 1750 PropertyDetails details(attributes, DATA, index);
1751 dict->SetNextEnumerationIndex(index + 1); 1751 dict->SetNextEnumerationIndex(index + 1);
1752 dict->SetEntry(entry, name, cell, details); 1752 dict->SetEntry(entry, name, cell, details);
1753 return; 1753 return;
1754 } 1754 }
1755 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value); 1755 value = isolate->factory()->NewPropertyCell(value);
1756 PropertyCell::SetValueInferType(cell, value);
1757 value = cell;
1758 } 1756 }
1759 PropertyDetails details(attributes, DATA, 0); 1757 PropertyDetails details(attributes, DATA, 0);
1760 Handle<NameDictionary> result = 1758 Handle<NameDictionary> result =
1761 NameDictionary::Add(dict, name, value, details); 1759 NameDictionary::Add(dict, name, value, details);
1762 if (*dict != *result) object->set_properties(*result); 1760 if (*dict != *result) object->set_properties(*result);
1763 } 1761 }
1764 1762
1765 1763
1766 Context* JSObject::GetCreationContext() { 1764 Context* JSObject::GetCreationContext() {
1767 Object* constructor = this->map()->constructor(); 1765 Object* constructor = this->map()->constructor();
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 NewTypeError("object_not_extensible", 3047 NewTypeError("object_not_extensible",
3050 HandleVector(args, arraysize(args))), 3048 HandleVector(args, arraysize(args))),
3051 Object); 3049 Object);
3052 } 3050 }
3053 it->ApplyTransitionToDataProperty(); 3051 it->ApplyTransitionToDataProperty();
3054 3052
3055 // TODO(verwaest): Encapsulate dictionary handling better. 3053 // TODO(verwaest): Encapsulate dictionary handling better.
3056 if (receiver->map()->is_dictionary_map()) { 3054 if (receiver->map()->is_dictionary_map()) {
3057 // TODO(verwaest): Probably should ensure this is done beforehand. 3055 // TODO(verwaest): Probably should ensure this is done beforehand.
3058 it->InternalizeName(); 3056 it->InternalizeName();
3057 // TODO(dcarney): just populate TransitionPropertyCell here?
3059 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); 3058 JSObject::AddSlowProperty(receiver, it->name(), value, attributes);
3060 } else { 3059 } else {
3061 // Write the property value. 3060 // Write the property value.
3062 value = it->WriteDataValue(value); 3061 value = it->WriteDataValue(value);
3063 } 3062 }
3064 3063
3065 // Send the change record if there are observers. 3064 // Send the change record if there are observers.
3066 if (receiver->map()->is_observed() && 3065 if (receiver->map()->is_observed() &&
3067 !it->isolate()->IsInternallyUsedPropertyName(it->name())) { 3066 !it->isolate()->IsInternallyUsedPropertyName(it->name())) {
3068 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord( 3067 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord(
(...skipping 12057 matching lines...) Expand 10 before | Expand all | Expand 10 after
15126 Handle<Object> value(cell->value(), isolate); 15125 Handle<Object> value(cell->value(), isolate);
15127 Handle<PropertyCell> new_cell = isolate->factory()->NewPropertyCell(value); 15126 Handle<PropertyCell> new_cell = isolate->factory()->NewPropertyCell(value);
15128 global->property_dictionary()->ValueAtPut(entry, *new_cell); 15127 global->property_dictionary()->ValueAtPut(entry, *new_cell);
15129 15128
15130 Handle<Object> hole = global->GetIsolate()->factory()->the_hole_value(); 15129 Handle<Object> hole = global->GetIsolate()->factory()->the_hole_value();
15131 PropertyCell::SetValueInferType(cell, hole); 15130 PropertyCell::SetValueInferType(cell, hole);
15132 } 15131 }
15133 } 15132 }
15134 15133
15135 15134
15136 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( 15135 Handle<PropertyCell> GlobalObject::EnsurePropertyCell(
15137 Handle<JSGlobalObject> global, 15136 Handle<GlobalObject> global, Handle<Name> name) {
15138 Handle<Name> name) {
15139 DCHECK(!global->HasFastProperties()); 15137 DCHECK(!global->HasFastProperties());
15140 int entry = global->property_dictionary()->FindEntry(name); 15138 int entry = global->property_dictionary()->FindEntry(name);
15141 if (entry == NameDictionary::kNotFound) { 15139 if (entry == NameDictionary::kNotFound) {
15142 Isolate* isolate = global->GetIsolate(); 15140 Isolate* isolate = global->GetIsolate();
15143 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( 15141 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCellWithHole();
15144 isolate->factory()->the_hole_value());
15145 PropertyDetails details(NONE, DATA, 0); 15142 PropertyDetails details(NONE, DATA, 0);
15146 details = details.AsDeleted(); 15143 details = details.AsDeleted();
15147 Handle<NameDictionary> dictionary = NameDictionary::Add( 15144 Handle<NameDictionary> dictionary = NameDictionary::Add(
15148 handle(global->property_dictionary()), name, cell, details); 15145 handle(global->property_dictionary()), name, cell, details);
15149 global->set_properties(*dictionary); 15146 global->set_properties(*dictionary);
15150 return cell; 15147 return cell;
15151 } else { 15148 } else {
15152 Object* value = global->property_dictionary()->ValueAt(entry); 15149 Object* value = global->property_dictionary()->ValueAt(entry);
15153 DCHECK(value->IsPropertyCell()); 15150 DCHECK(value->IsPropertyCell());
15154 return handle(PropertyCell::cast(value)); 15151 return handle(PropertyCell::cast(value));
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
16933 } 16930 }
16934 16931
16935 16932
16936 Handle<Object> PropertyCell::SetValueInferType(Handle<PropertyCell> cell, 16933 Handle<Object> PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
16937 Handle<Object> value) { 16934 Handle<Object> value) {
16938 // Heuristic: if a small-ish string is stored in a previously uninitialized 16935 // Heuristic: if a small-ish string is stored in a previously uninitialized
16939 // property cell, internalize it. 16936 // property cell, internalize it.
16940 const int kMaxLengthForInternalization = 200; 16937 const int kMaxLengthForInternalization = 200;
16941 if ((cell->type()->Is(HeapType::None()) || 16938 if ((cell->type()->Is(HeapType::None()) ||
16942 cell->type()->Is(HeapType::Undefined())) && 16939 cell->type()->Is(HeapType::Undefined())) &&
16943 value->IsString() && 16940 value->IsString()) {
16944 Handle<String>::cast(value)->length() <= kMaxLengthForInternalization) { 16941 auto string = Handle<String>::cast(value);
16945 value = cell->GetIsolate()->factory()->InternalizeString( 16942 if (string->length() <= kMaxLengthForInternalization &&
16946 Handle<String>::cast(value)); 16943 !string->map()->is_undetectable()) {
16944 value = cell->GetIsolate()->factory()->InternalizeString(string);
16945 }
16947 } 16946 }
16948 cell->set_value(*value); 16947 cell->set_value(*value);
16949 if (!HeapType::Any()->Is(cell->type())) { 16948 if (!HeapType::Any()->Is(cell->type())) {
16950 Handle<HeapType> new_type = UpdatedType(cell, value); 16949 Handle<HeapType> new_type = UpdatedType(cell, value);
16951 cell->set_type(*new_type); 16950 cell->set_type(*new_type);
16952 } 16951 }
16953 return value; 16952 return value;
16954 } 16953 }
16955 16954
16956 16955
16957 // static 16956 // static
16958 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell, 16957 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell,
16959 CompilationInfo* info) { 16958 CompilationInfo* info) {
16960 Handle<DependentCode> codes = 16959 Handle<DependentCode> codes =
16961 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16960 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16962 DependentCode::kPropertyCellChangedGroup, 16961 DependentCode::kPropertyCellChangedGroup,
16963 info->object_wrapper()); 16962 info->object_wrapper());
16964 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16963 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16965 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16964 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16966 cell, info->zone()); 16965 cell, info->zone());
16967 } 16966 }
16968 16967
16969 } } // namespace v8::internal 16968 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698