OLD | NEW |
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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 9958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9969 if (!object->HasFastProperties()) { | 9969 if (!object->HasFastProperties()) { |
9970 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); | 9970 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); |
9971 has_just_copied_map = true; | 9971 has_just_copied_map = true; |
9972 } | 9972 } |
9973 if (mode == FAST_PROTOTYPE && object->HasFastProperties() && | 9973 if (mode == FAST_PROTOTYPE && object->HasFastProperties() && |
9974 !object->map()->is_prototype_map()) { | 9974 !object->map()->is_prototype_map()) { |
9975 if (!has_just_copied_map) { | 9975 if (!has_just_copied_map) { |
9976 Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); | 9976 Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); |
9977 JSObject::MigrateToMap(object, new_map); | 9977 JSObject::MigrateToMap(object, new_map); |
9978 } | 9978 } |
| 9979 if (object->map()->constructor()->IsJSFunction()) { |
| 9980 JSFunction* constructor = JSFunction::cast(object->map()->constructor()); |
| 9981 // Replace the pointer to the exact constructor with the Object function |
| 9982 // from the same context if undetectable from JS. This is to avoid keeping |
| 9983 // memory alive unnecessarily. |
| 9984 if (!constructor->shared()->IsApiFunction() && |
| 9985 object->class_name() == |
| 9986 object->GetIsolate()->heap()->Object_string()) { |
| 9987 Context* context = constructor->context()->native_context(); |
| 9988 JSFunction* object_function = context->object_function(); |
| 9989 object->map()->set_constructor(object_function); |
| 9990 } |
| 9991 } |
9979 object->map()->set_is_prototype_map(true); | 9992 object->map()->set_is_prototype_map(true); |
9980 } | 9993 } |
9981 } | 9994 } |
9982 | 9995 |
9983 | 9996 |
9984 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { | 9997 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { |
9985 if (!object->map()->is_prototype_map()) return; | 9998 if (!object->map()->is_prototype_map()) return; |
9986 OptimizeAsPrototype(object, FAST_PROTOTYPE); | 9999 OptimizeAsPrototype(object, FAST_PROTOTYPE); |
9987 } | 10000 } |
9988 | 10001 |
(...skipping 7211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17200 CompilationInfo* info) { | 17213 CompilationInfo* info) { |
17201 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17214 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17202 handle(cell->dependent_code(), info->isolate()), | 17215 handle(cell->dependent_code(), info->isolate()), |
17203 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17216 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17204 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17217 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17205 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17218 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17206 cell, info->zone()); | 17219 cell, info->zone()); |
17207 } | 17220 } |
17208 | 17221 |
17209 } } // namespace v8::internal | 17222 } } // namespace v8::internal |
OLD | NEW |