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

Side by Side Diff: src/objects.cc

Issue 1005393004: Handlify Map::SetPrototype() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 5 years, 8 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/runtime/runtime-classes.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 6824 matching lines...) Expand 10 before | Expand all | Expand 10 after
6835 } 6835 }
6836 } 6836 }
6837 return GetHeap()->undefined_value(); 6837 return GetHeap()->undefined_value();
6838 } else { 6838 } else {
6839 return property_dictionary()->SlowReverseLookup(value); 6839 return property_dictionary()->SlowReverseLookup(value);
6840 } 6840 }
6841 } 6841 }
6842 6842
6843 6843
6844 Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) { 6844 Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) {
6845 Handle<Map> result = map->GetIsolate()->factory()->NewMap( 6845 Isolate* isolate = map->GetIsolate();
6846 map->instance_type(), instance_size); 6846 Handle<Map> result =
6847 result->SetPrototype(handle(map->prototype(), map->GetIsolate())); 6847 isolate->factory()->NewMap(map->instance_type(), instance_size);
6848 Handle<Object> prototype(map->prototype(), isolate);
6849 Map::SetPrototype(result, prototype);
6848 result->set_constructor_or_backpointer(map->GetConstructor()); 6850 result->set_constructor_or_backpointer(map->GetConstructor());
6849 result->set_bit_field(map->bit_field()); 6851 result->set_bit_field(map->bit_field());
6850 result->set_bit_field2(map->bit_field2()); 6852 result->set_bit_field2(map->bit_field2());
6851 int new_bit_field3 = map->bit_field3(); 6853 int new_bit_field3 = map->bit_field3();
6852 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); 6854 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true);
6853 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); 6855 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0);
6854 new_bit_field3 = EnumLengthBits::update(new_bit_field3, 6856 new_bit_field3 = EnumLengthBits::update(new_bit_field3,
6855 kInvalidEnumCacheSentinel); 6857 kInvalidEnumCacheSentinel);
6856 new_bit_field3 = Deprecated::update(new_bit_field3, false); 6858 new_bit_field3 = Deprecated::update(new_bit_field3, false);
6857 if (!map->is_dictionary_map()) { 6859 if (!map->is_dictionary_map()) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
7032 parent->set_owns_descriptors(false); 7034 parent->set_owns_descriptors(false);
7033 if (parent->is_prototype_map()) { 7035 if (parent->is_prototype_map()) {
7034 DCHECK(child->is_prototype_map()); 7036 DCHECK(child->is_prototype_map());
7035 #if TRACE_MAPS 7037 #if TRACE_MAPS
7036 Map::TraceTransition("NoTransition", *parent, *child, *name); 7038 Map::TraceTransition("NoTransition", *parent, *child, *name);
7037 #endif 7039 #endif
7038 } else { 7040 } else {
7039 TransitionArray::Insert(parent, name, child, flag); 7041 TransitionArray::Insert(parent, name, child, flag);
7040 if (child->prototype()->IsJSObject()) { 7042 if (child->prototype()->IsJSObject()) {
7041 Handle<JSObject> proto(JSObject::cast(child->prototype())); 7043 Handle<JSObject> proto(JSObject::cast(child->prototype()));
7042 if (!child->ShouldRegisterAsPrototypeUser(proto)) { 7044 if (!ShouldRegisterAsPrototypeUser(child, proto)) {
7043 JSObject::UnregisterPrototypeUser(proto, child); 7045 JSObject::UnregisterPrototypeUser(proto, child);
7044 } 7046 }
7045 } 7047 }
7046 #if TRACE_MAPS 7048 #if TRACE_MAPS
7047 Map::TraceTransition("Transition", *parent, *child, *name); 7049 Map::TraceTransition("Transition", *parent, *child, *name);
7048 #endif 7050 #endif
7049 } 7051 }
7050 } 7052 }
7051 7053
7052 7054
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after
10033 Object* maybe_proto_info = prototype->map()->prototype_info(); 10035 Object* maybe_proto_info = prototype->map()->prototype_info();
10034 if (!maybe_proto_info->IsPrototypeInfo()) return; 10036 if (!maybe_proto_info->IsPrototypeInfo()) return;
10035 Handle<PrototypeInfo> proto_info(PrototypeInfo::cast(maybe_proto_info), 10037 Handle<PrototypeInfo> proto_info(PrototypeInfo::cast(maybe_proto_info),
10036 isolate); 10038 isolate);
10037 Object* maybe_registry = proto_info->prototype_users(); 10039 Object* maybe_registry = proto_info->prototype_users();
10038 if (!maybe_registry->IsWeakFixedArray()) return; 10040 if (!maybe_registry->IsWeakFixedArray()) return;
10039 WeakFixedArray::cast(maybe_registry)->Remove(user); 10041 WeakFixedArray::cast(maybe_registry)->Remove(user);
10040 } 10042 }
10041 10043
10042 10044
10043 void Map::SetPrototype(Handle<Object> prototype, 10045 // static
10046 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype,
10044 PrototypeOptimizationMode proto_mode) { 10047 PrototypeOptimizationMode proto_mode) {
10045 if (this->prototype()->IsJSObject() && FLAG_track_prototype_users) { 10048 if (map->prototype()->IsJSObject() && FLAG_track_prototype_users) {
10046 Handle<JSObject> old_prototype(JSObject::cast(this->prototype())); 10049 Handle<JSObject> old_prototype(JSObject::cast(map->prototype()));
10047 JSObject::UnregisterPrototypeUser(old_prototype, handle(this)); 10050 JSObject::UnregisterPrototypeUser(old_prototype, map);
10048 } 10051 }
10049 if (prototype->IsJSObject()) { 10052 if (prototype->IsJSObject()) {
10050 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); 10053 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype);
10051 if (ShouldRegisterAsPrototypeUser(prototype_jsobj)) { 10054 if (ShouldRegisterAsPrototypeUser(map, prototype_jsobj)) {
10052 JSObject::RegisterPrototypeUser(prototype_jsobj, handle(this)); 10055 JSObject::RegisterPrototypeUser(prototype_jsobj, map);
10053 } 10056 }
10054 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); 10057 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode);
10055 } 10058 }
10056 WriteBarrierMode wb_mode = 10059 WriteBarrierMode wb_mode =
10057 prototype->IsNull() ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; 10060 prototype->IsNull() ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER;
10058 set_prototype(*prototype, wb_mode); 10061 map->set_prototype(*prototype, wb_mode);
10059 } 10062 }
10060 10063
10061 10064
10062 bool Map::ShouldRegisterAsPrototypeUser(Handle<JSObject> prototype) { 10065 // static
10066 bool Map::ShouldRegisterAsPrototypeUser(Handle<Map> map,
10067 Handle<JSObject> prototype) {
10063 if (!FLAG_track_prototype_users) return false; 10068 if (!FLAG_track_prototype_users) return false;
10064 if (this->is_prototype_map()) return true; 10069 if (map->is_prototype_map()) return true;
10065 Object* back = GetBackPointer(); 10070 Object* back = map->GetBackPointer();
10066 if (!back->IsMap()) return true; 10071 if (!back->IsMap()) return true;
10067 if (Map::cast(back)->prototype() != *prototype) return true; 10072 if (Map::cast(back)->prototype() != *prototype) return true;
10068 return false; 10073 return false;
10069 } 10074 }
10070 10075
10071 10076
10072 Handle<Object> CacheInitialJSArrayMaps( 10077 Handle<Object> CacheInitialJSArrayMaps(
10073 Handle<Context> native_context, Handle<Map> initial_map) { 10078 Handle<Context> native_context, Handle<Map> initial_map) {
10074 // Replace all of the cached initial array maps in the native context with 10079 // Replace all of the cached initial array maps in the native context with
10075 // the appropriate transitioned elements kind maps. 10080 // the appropriate transitioned elements kind maps.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
10208 10213
10209 set_map(no_prototype_map); 10214 set_map(no_prototype_map);
10210 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value()); 10215 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value());
10211 return true; 10216 return true;
10212 } 10217 }
10213 10218
10214 10219
10215 void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map, 10220 void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
10216 Handle<Object> prototype) { 10221 Handle<Object> prototype) {
10217 if (map->prototype() != *prototype) { 10222 if (map->prototype() != *prototype) {
10218 map->SetPrototype(prototype, FAST_PROTOTYPE); 10223 Map::SetPrototype(map, prototype, FAST_PROTOTYPE);
10219 } 10224 }
10220 function->set_prototype_or_initial_map(*map); 10225 function->set_prototype_or_initial_map(*map);
10221 map->SetConstructor(*function); 10226 map->SetConstructor(*function);
10222 #if TRACE_MAPS 10227 #if TRACE_MAPS
10223 if (FLAG_trace_maps) { 10228 if (FLAG_trace_maps) {
10224 PrintF("[TraceMaps: InitialMap map= %p SFI= %d_%s ]\n", 10229 PrintF("[TraceMaps: InitialMap map= %p SFI= %d_%s ]\n",
10225 reinterpret_cast<void*>(*map), function->shared()->unique_id(), 10230 reinterpret_cast<void*>(*map), function->shared()->unique_id(),
10226 function->shared()->DebugName()->ToCString().get()); 10231 function->shared()->DebugName()->ToCString().get());
10227 } 10232 }
10228 #endif 10233 #endif
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
12339 } 12344 }
12340 12345
12341 12346
12342 Handle<Map> Map::TransitionToPrototype(Handle<Map> map, 12347 Handle<Map> Map::TransitionToPrototype(Handle<Map> map,
12343 Handle<Object> prototype, 12348 Handle<Object> prototype,
12344 PrototypeOptimizationMode mode) { 12349 PrototypeOptimizationMode mode) {
12345 Handle<Map> new_map = TransitionArray::GetPrototypeTransition(map, prototype); 12350 Handle<Map> new_map = TransitionArray::GetPrototypeTransition(map, prototype);
12346 if (new_map.is_null()) { 12351 if (new_map.is_null()) {
12347 new_map = Copy(map, "TransitionToPrototype"); 12352 new_map = Copy(map, "TransitionToPrototype");
12348 TransitionArray::PutPrototypeTransition(map, prototype, new_map); 12353 TransitionArray::PutPrototypeTransition(map, prototype, new_map);
12349 new_map->SetPrototype(prototype, mode); 12354 Map::SetPrototype(new_map, prototype, mode);
12350 } 12355 }
12351 return new_map; 12356 return new_map;
12352 } 12357 }
12353 12358
12354 12359
12355 MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object, 12360 MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
12356 Handle<Object> value, 12361 Handle<Object> value,
12357 bool from_javascript) { 12362 bool from_javascript) {
12358 #ifdef DEBUG 12363 #ifdef DEBUG
12359 int size = object->Size(); 12364 int size = object->Size();
(...skipping 4686 matching lines...) Expand 10 before | Expand all | Expand 10 after
17046 CompilationInfo* info) { 17051 CompilationInfo* info) {
17047 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17052 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17048 handle(cell->dependent_code(), info->isolate()), 17053 handle(cell->dependent_code(), info->isolate()),
17049 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17054 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17050 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17055 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17051 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17056 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17052 cell, info->zone()); 17057 cell, info->zone());
17053 } 17058 }
17054 17059
17055 } } // namespace v8::internal 17060 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698