| 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 9161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9172 | 9172 |
| 9173 | 9173 |
| 9174 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, | 9174 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, |
| 9175 Handle<Object> value, | 9175 Handle<Object> value, |
| 9176 PropertyAttributes attributes, | 9176 PropertyAttributes attributes, |
| 9177 StoreFromKeyed store_mode) { | 9177 StoreFromKeyed store_mode) { |
| 9178 RuntimeCallTimerScope stats_scope( | 9178 RuntimeCallTimerScope stats_scope( |
| 9179 *map, map->is_prototype_map() | 9179 *map, map->is_prototype_map() |
| 9180 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty | 9180 ? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty |
| 9181 : &RuntimeCallStats::Map_TransitionToDataProperty); | 9181 : &RuntimeCallStats::Map_TransitionToDataProperty); |
| 9182 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 9183 map->GetIsolate(), |
| 9184 (map->is_prototype_map() |
| 9185 ? &tracing::TraceEventStatsTable:: |
| 9186 PrototypeMap_TransitionToDataProperty |
| 9187 : &tracing::TraceEventStatsTable::Map_TransitionToDataProperty)) |
| 9182 | 9188 |
| 9183 DCHECK(name->IsUniqueName()); | 9189 DCHECK(name->IsUniqueName()); |
| 9184 DCHECK(!map->is_dictionary_map()); | 9190 DCHECK(!map->is_dictionary_map()); |
| 9185 | 9191 |
| 9186 // Migrate to the newest map before storing the property. | 9192 // Migrate to the newest map before storing the property. |
| 9187 map = Update(map); | 9193 map = Update(map); |
| 9188 | 9194 |
| 9189 Map* maybe_transition = | 9195 Map* maybe_transition = |
| 9190 TransitionArray::SearchTransition(*map, kData, *name, attributes); | 9196 TransitionArray::SearchTransition(*map, kData, *name, attributes); |
| 9191 if (maybe_transition != NULL) { | 9197 if (maybe_transition != NULL) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9258 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, | 9264 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, |
| 9259 Handle<Name> name, int descriptor, | 9265 Handle<Name> name, int descriptor, |
| 9260 Handle<Object> getter, | 9266 Handle<Object> getter, |
| 9261 Handle<Object> setter, | 9267 Handle<Object> setter, |
| 9262 PropertyAttributes attributes) { | 9268 PropertyAttributes attributes) { |
| 9263 RuntimeCallTimerScope stats_scope( | 9269 RuntimeCallTimerScope stats_scope( |
| 9264 isolate, | 9270 isolate, |
| 9265 map->is_prototype_map() | 9271 map->is_prototype_map() |
| 9266 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty | 9272 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty |
| 9267 : &RuntimeCallStats::Map_TransitionToAccessorProperty); | 9273 : &RuntimeCallStats::Map_TransitionToAccessorProperty); |
| 9274 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 9275 isolate, |
| 9276 (map->is_prototype_map() |
| 9277 ? &tracing::TraceEventStatsTable:: |
| 9278 PrototypeMap_TransitionToAccessorProperty |
| 9279 : &tracing::TraceEventStatsTable::Map_TransitionToAccessorProperty)); |
| 9268 | 9280 |
| 9269 // At least one of the accessors needs to be a new value. | 9281 // At least one of the accessors needs to be a new value. |
| 9270 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); | 9282 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); |
| 9271 DCHECK(name->IsUniqueName()); | 9283 DCHECK(name->IsUniqueName()); |
| 9272 | 9284 |
| 9273 // Dictionary maps can always have additional data properties. | 9285 // Dictionary maps can always have additional data properties. |
| 9274 if (map->is_dictionary_map()) return map; | 9286 if (map->is_dictionary_map()) return map; |
| 9275 | 9287 |
| 9276 // Migrate to the newest map before transitioning to the new property. | 9288 // Migrate to the newest map before transitioning to the new property. |
| 9277 map = Update(map); | 9289 map = Update(map); |
| (...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12157 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); | 12169 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); |
| 12158 proto_info->set_validity_cell(*cell); | 12170 proto_info->set_validity_cell(*cell); |
| 12159 return cell; | 12171 return cell; |
| 12160 } | 12172 } |
| 12161 | 12173 |
| 12162 | 12174 |
| 12163 // static | 12175 // static |
| 12164 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, | 12176 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, |
| 12165 PrototypeOptimizationMode proto_mode) { | 12177 PrototypeOptimizationMode proto_mode) { |
| 12166 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); | 12178 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); |
| 12179 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 12180 map->GetIsolate(), &tracing::TraceEventStatsTable::Map_SetPrototype); |
| 12167 | 12181 |
| 12168 bool is_hidden = false; | 12182 bool is_hidden = false; |
| 12169 if (prototype->IsJSObject()) { | 12183 if (prototype->IsJSObject()) { |
| 12170 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); | 12184 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); |
| 12171 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); | 12185 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); |
| 12172 | 12186 |
| 12173 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); | 12187 Object* maybe_constructor = prototype_jsobj->map()->GetConstructor(); |
| 12174 if (maybe_constructor->IsJSFunction()) { | 12188 if (maybe_constructor->IsJSFunction()) { |
| 12175 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 12189 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
| 12176 Object* data = constructor->shared()->function_data(); | 12190 Object* data = constructor->shared()->function_data(); |
| (...skipping 6832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19009 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19023 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
| 19010 PrototypeIterator::END_AT_NULL); | 19024 PrototypeIterator::END_AT_NULL); |
| 19011 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19025 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
| 19012 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19026 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
| 19013 } | 19027 } |
| 19014 return false; | 19028 return false; |
| 19015 } | 19029 } |
| 19016 | 19030 |
| 19017 } // namespace internal | 19031 } // namespace internal |
| 19018 } // namespace v8 | 19032 } // namespace v8 |
| OLD | NEW |