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 9435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9446 | 9446 |
9447 | 9447 |
9448 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, | 9448 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, |
9449 Handle<Object> value, | 9449 Handle<Object> value, |
9450 PropertyAttributes attributes, | 9450 PropertyAttributes attributes, |
9451 StoreFromKeyed store_mode) { | 9451 StoreFromKeyed store_mode) { |
9452 RuntimeCallTimerScope stats_scope( | 9452 RuntimeCallTimerScope stats_scope( |
9453 *map, map->is_prototype_map() | 9453 *map, map->is_prototype_map() |
9454 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty | 9454 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty |
9455 : &RuntimeCallStats::Map_TransitionToDataProperty); | 9455 : &RuntimeCallStats::Map_TransitionToDataProperty); |
9456 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
9457 map->GetIsolate(), | |
9458 (map->is_prototype_map() | |
9459 ? &tracing::TraceEventStatsTable:: | |
9460 PrototypeMap_TransitionToDataProperty | |
9461 : &tracing::TraceEventStatsTable::Map_TransitionToDataProperty)) | |
9462 | 9456 |
9463 DCHECK(name->IsUniqueName()); | 9457 DCHECK(name->IsUniqueName()); |
9464 DCHECK(!map->is_dictionary_map()); | 9458 DCHECK(!map->is_dictionary_map()); |
9465 | 9459 |
9466 // Migrate to the newest map before storing the property. | 9460 // Migrate to the newest map before storing the property. |
9467 map = Update(map); | 9461 map = Update(map); |
9468 | 9462 |
9469 Map* maybe_transition = | 9463 Map* maybe_transition = |
9470 TransitionArray::SearchTransition(*map, kData, *name, attributes); | 9464 TransitionArray::SearchTransition(*map, kData, *name, attributes); |
9471 if (maybe_transition != NULL) { | 9465 if (maybe_transition != NULL) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9538 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, | 9532 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, |
9539 Handle<Name> name, int descriptor, | 9533 Handle<Name> name, int descriptor, |
9540 Handle<Object> getter, | 9534 Handle<Object> getter, |
9541 Handle<Object> setter, | 9535 Handle<Object> setter, |
9542 PropertyAttributes attributes) { | 9536 PropertyAttributes attributes) { |
9543 RuntimeCallTimerScope stats_scope( | 9537 RuntimeCallTimerScope stats_scope( |
9544 isolate, | 9538 isolate, |
9545 map->is_prototype_map() | 9539 map->is_prototype_map() |
9546 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty | 9540 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty |
9547 : &RuntimeCallStats::Map_TransitionToAccessorProperty); | 9541 : &RuntimeCallStats::Map_TransitionToAccessorProperty); |
9548 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
9549 isolate, | |
9550 (map->is_prototype_map() | |
9551 ? &tracing::TraceEventStatsTable:: | |
9552 PrototypeMap_TransitionToAccessorProperty | |
9553 : &tracing::TraceEventStatsTable::Map_TransitionToAccessorProperty)); | |
9554 | 9542 |
9555 // At least one of the accessors needs to be a new value. | 9543 // At least one of the accessors needs to be a new value. |
9556 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); | 9544 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); |
9557 DCHECK(name->IsUniqueName()); | 9545 DCHECK(name->IsUniqueName()); |
9558 | 9546 |
9559 // Dictionary maps can always have additional data properties. | 9547 // Dictionary maps can always have additional data properties. |
9560 if (map->is_dictionary_map()) return map; | 9548 if (map->is_dictionary_map()) return map; |
9561 | 9549 |
9562 // Migrate to the newest map before transitioning to the new property. | 9550 // Migrate to the newest map before transitioning to the new property. |
9563 map = Update(map); | 9551 map = Update(map); |
(...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12494 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); | 12482 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); |
12495 proto_info->set_validity_cell(*cell); | 12483 proto_info->set_validity_cell(*cell); |
12496 return cell; | 12484 return cell; |
12497 } | 12485 } |
12498 | 12486 |
12499 | 12487 |
12500 // static | 12488 // static |
12501 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, | 12489 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, |
12502 PrototypeOptimizationMode proto_mode) { | 12490 PrototypeOptimizationMode proto_mode) { |
12503 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); | 12491 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); |
12504 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
12505 map->GetIsolate(), &tracing::TraceEventStatsTable::Map_SetPrototype); | |
12506 | 12492 |
12507 bool is_hidden = false; | 12493 bool is_hidden = false; |
12508 if (prototype->IsJSObject()) { | 12494 if (prototype->IsJSObject()) { |
12509 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); | 12495 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); |
12510 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); | 12496 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); |
12511 | 12497 |
12512 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); | 12498 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); |
12513 if (maybe_constructor->IsJSFunction()) { | 12499 if (maybe_constructor->IsJSFunction()) { |
12514 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 12500 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
12515 Object* data = constructor->shared()->function_data(); | 12501 Object* data = constructor->shared()->function_data(); |
(...skipping 6915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19431 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19417 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
19432 PrototypeIterator::END_AT_NULL); | 19418 PrototypeIterator::END_AT_NULL); |
19433 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19419 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
19434 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19420 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
19435 } | 19421 } |
19436 return false; | 19422 return false; |
19437 } | 19423 } |
19438 | 19424 |
19439 } // namespace internal | 19425 } // namespace internal |
19440 } // namespace v8 | 19426 } // namespace v8 |
OLD | NEW |