| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 9179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9190 | 9190 |
| 9191 | 9191 |
| 9192 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, | 9192 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, |
| 9193 Handle<Object> value, | 9193 Handle<Object> value, |
| 9194 PropertyAttributes attributes, | 9194 PropertyAttributes attributes, |
| 9195 StoreFromKeyed store_mode) { | 9195 StoreFromKeyed store_mode) { |
| 9196 RuntimeCallTimerScope stats_scope( | 9196 RuntimeCallTimerScope stats_scope( |
| 9197 *map, map->is_prototype_map() | 9197 *map, map->is_prototype_map() |
| 9198 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty | 9198 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty |
| 9199 : &RuntimeCallStats::Map_TransitionToDataProperty); | 9199 : &RuntimeCallStats::Map_TransitionToDataProperty); |
| 9200 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
| 9201 map->GetIsolate(), | |
| 9202 (map->is_prototype_map() | |
| 9203 ? &tracing::TraceEventStatsTable:: | |
| 9204 PrototypeMap_TransitionToDataProperty | |
| 9205 : &tracing::TraceEventStatsTable::Map_TransitionToDataProperty)) | |
| 9206 | 9200 |
| 9207 DCHECK(name->IsUniqueName()); | 9201 DCHECK(name->IsUniqueName()); |
| 9208 DCHECK(!map->is_dictionary_map()); | 9202 DCHECK(!map->is_dictionary_map()); |
| 9209 | 9203 |
| 9210 // Migrate to the newest map before storing the property. | 9204 // Migrate to the newest map before storing the property. |
| 9211 map = Update(map); | 9205 map = Update(map); |
| 9212 | 9206 |
| 9213 Map* maybe_transition = | 9207 Map* maybe_transition = |
| 9214 TransitionArray::SearchTransition(*map, kData, *name, attributes); | 9208 TransitionArray::SearchTransition(*map, kData, *name, attributes); |
| 9215 if (maybe_transition != NULL) { | 9209 if (maybe_transition != NULL) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9282 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, | 9276 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, |
| 9283 Handle<Name> name, int descriptor, | 9277 Handle<Name> name, int descriptor, |
| 9284 Handle<Object> getter, | 9278 Handle<Object> getter, |
| 9285 Handle<Object> setter, | 9279 Handle<Object> setter, |
| 9286 PropertyAttributes attributes) { | 9280 PropertyAttributes attributes) { |
| 9287 RuntimeCallTimerScope stats_scope( | 9281 RuntimeCallTimerScope stats_scope( |
| 9288 isolate, | 9282 isolate, |
| 9289 map->is_prototype_map() | 9283 map->is_prototype_map() |
| 9290 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty | 9284 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty |
| 9291 : &RuntimeCallStats::Map_TransitionToAccessorProperty); | 9285 : &RuntimeCallStats::Map_TransitionToAccessorProperty); |
| 9292 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
| 9293 isolate, | |
| 9294 (map->is_prototype_map() | |
| 9295 ? &tracing::TraceEventStatsTable:: | |
| 9296 PrototypeMap_TransitionToAccessorProperty | |
| 9297 : &tracing::TraceEventStatsTable::Map_TransitionToAccessorProperty)); | |
| 9298 | 9286 |
| 9299 // At least one of the accessors needs to be a new value. | 9287 // At least one of the accessors needs to be a new value. |
| 9300 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); | 9288 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); |
| 9301 DCHECK(name->IsUniqueName()); | 9289 DCHECK(name->IsUniqueName()); |
| 9302 | 9290 |
| 9303 // Dictionary maps can always have additional data properties. | 9291 // Dictionary maps can always have additional data properties. |
| 9304 if (map->is_dictionary_map()) return map; | 9292 if (map->is_dictionary_map()) return map; |
| 9305 | 9293 |
| 9306 // Migrate to the newest map before transitioning to the new property. | 9294 // Migrate to the newest map before transitioning to the new property. |
| 9307 map = Update(map); | 9295 map = Update(map); |
| (...skipping 2876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12184 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); | 12172 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); |
| 12185 proto_info->set_validity_cell(*cell); | 12173 proto_info->set_validity_cell(*cell); |
| 12186 return cell; | 12174 return cell; |
| 12187 } | 12175 } |
| 12188 | 12176 |
| 12189 | 12177 |
| 12190 // static | 12178 // static |
| 12191 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, | 12179 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, |
| 12192 PrototypeOptimizationMode proto_mode) { | 12180 PrototypeOptimizationMode proto_mode) { |
| 12193 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); | 12181 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); |
| 12194 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
| 12195 map->GetIsolate(), &tracing::TraceEventStatsTable::Map_SetPrototype); | |
| 12196 | 12182 |
| 12197 bool is_hidden = false; | 12183 bool is_hidden = false; |
| 12198 if (prototype->IsJSObject()) { | 12184 if (prototype->IsJSObject()) { |
| 12199 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); | 12185 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); |
| 12200 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); | 12186 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); |
| 12201 | 12187 |
| 12202 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); | 12188 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); |
| 12203 if (maybe_constructor->IsJSFunction()) { | 12189 if (maybe_constructor->IsJSFunction()) { |
| 12204 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 12190 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
| 12205 Object* data = constructor->shared()->function_data(); | 12191 Object* data = constructor->shared()->function_data(); |
| (...skipping 6845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19051 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19037 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
| 19052 PrototypeIterator::END_AT_NULL); | 19038 PrototypeIterator::END_AT_NULL); |
| 19053 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19039 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
| 19054 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19040 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
| 19055 } | 19041 } |
| 19056 return false; | 19042 return false; |
| 19057 } | 19043 } |
| 19058 | 19044 |
| 19059 } // namespace internal | 19045 } // namespace internal |
| 19060 } // namespace v8 | 19046 } // namespace v8 |
| OLD | NEW |