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 9342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9353 | 9353 |
9354 | 9354 |
9355 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, | 9355 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, |
9356 Handle<Object> value, | 9356 Handle<Object> value, |
9357 PropertyAttributes attributes, | 9357 PropertyAttributes attributes, |
9358 StoreFromKeyed store_mode) { | 9358 StoreFromKeyed store_mode) { |
9359 RuntimeCallTimerScope stats_scope( | 9359 RuntimeCallTimerScope stats_scope( |
9360 *map, map->is_prototype_map() | 9360 *map, map->is_prototype_map() |
9361 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty | 9361 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty |
9362 : &RuntimeCallStats::Map_TransitionToDataProperty); | 9362 : &RuntimeCallStats::Map_TransitionToDataProperty); |
9363 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
9364 map->GetIsolate(), | |
9365 (map->is_prototype_map() | |
9366 ? &tracing::TraceEventStatsTable:: | |
9367 PrototypeMap_TransitionToDataProperty | |
9368 : &tracing::TraceEventStatsTable::Map_TransitionToDataProperty)) | |
9369 | 9363 |
9370 DCHECK(name->IsUniqueName()); | 9364 DCHECK(name->IsUniqueName()); |
9371 DCHECK(!map->is_dictionary_map()); | 9365 DCHECK(!map->is_dictionary_map()); |
9372 | 9366 |
9373 // Migrate to the newest map before storing the property. | 9367 // Migrate to the newest map before storing the property. |
9374 map = Update(map); | 9368 map = Update(map); |
9375 | 9369 |
9376 Map* maybe_transition = | 9370 Map* maybe_transition = |
9377 TransitionArray::SearchTransition(*map, kData, *name, attributes); | 9371 TransitionArray::SearchTransition(*map, kData, *name, attributes); |
9378 if (maybe_transition != NULL) { | 9372 if (maybe_transition != NULL) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9445 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, | 9439 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, |
9446 Handle<Name> name, int descriptor, | 9440 Handle<Name> name, int descriptor, |
9447 Handle<Object> getter, | 9441 Handle<Object> getter, |
9448 Handle<Object> setter, | 9442 Handle<Object> setter, |
9449 PropertyAttributes attributes) { | 9443 PropertyAttributes attributes) { |
9450 RuntimeCallTimerScope stats_scope( | 9444 RuntimeCallTimerScope stats_scope( |
9451 isolate, | 9445 isolate, |
9452 map->is_prototype_map() | 9446 map->is_prototype_map() |
9453 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty | 9447 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty |
9454 : &RuntimeCallStats::Map_TransitionToAccessorProperty); | 9448 : &RuntimeCallStats::Map_TransitionToAccessorProperty); |
9455 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
9456 isolate, | |
9457 (map->is_prototype_map() | |
9458 ? &tracing::TraceEventStatsTable:: | |
9459 PrototypeMap_TransitionToAccessorProperty | |
9460 : &tracing::TraceEventStatsTable::Map_TransitionToAccessorProperty)); | |
9461 | 9449 |
9462 // At least one of the accessors needs to be a new value. | 9450 // At least one of the accessors needs to be a new value. |
9463 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); | 9451 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); |
9464 DCHECK(name->IsUniqueName()); | 9452 DCHECK(name->IsUniqueName()); |
9465 | 9453 |
9466 // Dictionary maps can always have additional data properties. | 9454 // Dictionary maps can always have additional data properties. |
9467 if (map->is_dictionary_map()) return map; | 9455 if (map->is_dictionary_map()) return map; |
9468 | 9456 |
9469 // Migrate to the newest map before transitioning to the new property. | 9457 // Migrate to the newest map before transitioning to the new property. |
9470 map = Update(map); | 9458 map = Update(map); |
(...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12401 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); | 12389 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); |
12402 proto_info->set_validity_cell(*cell); | 12390 proto_info->set_validity_cell(*cell); |
12403 return cell; | 12391 return cell; |
12404 } | 12392 } |
12405 | 12393 |
12406 | 12394 |
12407 // static | 12395 // static |
12408 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, | 12396 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, |
12409 PrototypeOptimizationMode proto_mode) { | 12397 PrototypeOptimizationMode proto_mode) { |
12410 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); | 12398 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); |
12411 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
12412 map->GetIsolate(), &tracing::TraceEventStatsTable::Map_SetPrototype); | |
12413 | 12399 |
12414 bool is_hidden = false; | 12400 bool is_hidden = false; |
12415 if (prototype->IsJSObject()) { | 12401 if (prototype->IsJSObject()) { |
12416 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); | 12402 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); |
12417 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); | 12403 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); |
12418 | 12404 |
12419 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); | 12405 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); |
12420 if (maybe_constructor->IsJSFunction()) { | 12406 if (maybe_constructor->IsJSFunction()) { |
12421 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 12407 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
12422 Object* data = constructor->shared()->function_data(); | 12408 Object* data = constructor->shared()->function_data(); |
(...skipping 6915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19338 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19324 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
19339 PrototypeIterator::END_AT_NULL); | 19325 PrototypeIterator::END_AT_NULL); |
19340 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19326 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
19341 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19327 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
19342 } | 19328 } |
19343 return false; | 19329 return false; |
19344 } | 19330 } |
19345 | 19331 |
19346 } // namespace internal | 19332 } // namespace internal |
19347 } // namespace v8 | 19333 } // namespace v8 |
OLD | NEW |