Chromium Code Reviews| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 4049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4060 } | 4060 } |
| 4061 | 4061 |
| 4062 | 4062 |
| 4063 void JSObject::ConvertAndSetOwnProperty(LookupResult* lookup, | 4063 void JSObject::ConvertAndSetOwnProperty(LookupResult* lookup, |
| 4064 Handle<Name> name, | 4064 Handle<Name> name, |
| 4065 Handle<Object> value, | 4065 Handle<Object> value, |
| 4066 PropertyAttributes attributes) { | 4066 PropertyAttributes attributes) { |
| 4067 Handle<JSObject> object(lookup->holder()); | 4067 Handle<JSObject> object(lookup->holder()); |
| 4068 if (object->map()->TooManyFastProperties(Object::MAY_BE_STORE_FROM_KEYED)) { | 4068 if (object->map()->TooManyFastProperties(Object::MAY_BE_STORE_FROM_KEYED)) { |
| 4069 JSObject::NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 4069 JSObject::NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4070 } else if (object->map()->is_prototype_map()) { | |
| 4071 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0); | |
| 4070 } | 4072 } |
| 4071 | 4073 |
| 4072 if (!object->HasFastProperties()) { | 4074 if (!object->HasFastProperties()) { |
| 4073 ReplaceSlowProperty(object, name, value, attributes); | 4075 ReplaceSlowProperty(object, name, value, attributes); |
| 4076 ReoptimizeIfPrototype(object); | |
| 4074 return; | 4077 return; |
| 4075 } | 4078 } |
| 4076 | 4079 |
| 4077 int descriptor_index = lookup->GetDescriptorIndex(); | 4080 int descriptor_index = lookup->GetDescriptorIndex(); |
| 4078 if (lookup->GetAttributes() == attributes) { | 4081 if (lookup->GetAttributes() == attributes) { |
| 4079 JSObject::GeneralizeFieldRepresentation(object, descriptor_index, | 4082 JSObject::GeneralizeFieldRepresentation(object, descriptor_index, |
| 4080 Representation::Tagged(), | 4083 Representation::Tagged(), |
| 4081 HeapType::Any(lookup->isolate())); | 4084 HeapType::Any(lookup->isolate())); |
| 4082 } else { | 4085 } else { |
| 4083 Handle<Map> old_map(object->map()); | 4086 Handle<Map> old_map(object->map()); |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5144 | 5147 |
| 5145 SetOwnPropertyIgnoreAttributes(object, isolate->factory()->hidden_string(), | 5148 SetOwnPropertyIgnoreAttributes(object, isolate->factory()->hidden_string(), |
| 5146 value, DONT_ENUM, | 5149 value, DONT_ENUM, |
| 5147 OMIT_EXTENSIBILITY_CHECK).Assert(); | 5150 OMIT_EXTENSIBILITY_CHECK).Assert(); |
| 5148 return object; | 5151 return object; |
| 5149 } | 5152 } |
| 5150 | 5153 |
| 5151 | 5154 |
| 5152 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object, | 5155 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object, |
| 5153 Handle<Name> name, | 5156 Handle<Name> name, |
| 5154 DeleteMode mode) { | 5157 DeleteMode delete_mode) { |
| 5155 // Check own property, ignore interceptor. | 5158 // Check own property, ignore interceptor. |
| 5156 Isolate* isolate = object->GetIsolate(); | 5159 Isolate* isolate = object->GetIsolate(); |
| 5157 LookupResult result(isolate); | 5160 LookupResult lookup(isolate); |
| 5158 object->LookupOwnRealNamedProperty(name, &result); | 5161 object->LookupOwnRealNamedProperty(name, &lookup); |
| 5159 if (!result.IsFound()) return isolate->factory()->true_value(); | 5162 if (!lookup.IsFound()) return isolate->factory()->true_value(); |
| 5160 | 5163 |
| 5164 PropertyNormalizationMode mode = object->map()->is_prototype_map() | |
| 5165 ? KEEP_INOBJECT_PROPERTIES | |
| 5166 : CLEAR_INOBJECT_PROPERTIES; | |
| 5161 // Normalize object if needed. | 5167 // Normalize object if needed. |
| 5162 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 5168 NormalizeProperties(object, mode, 0); |
| 5163 | 5169 |
| 5164 return DeleteNormalizedProperty(object, name, mode); | 5170 Handle<Object> result = DeleteNormalizedProperty(object, name, delete_mode); |
| 5171 ReoptimizeIfPrototype(object); | |
| 5172 return result; | |
| 5165 } | 5173 } |
| 5166 | 5174 |
| 5167 | 5175 |
| 5168 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor( | 5176 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor( |
| 5169 Handle<JSObject> object, Handle<Name> name) { | 5177 Handle<JSObject> object, Handle<Name> name) { |
| 5170 Isolate* isolate = object->GetIsolate(); | 5178 Isolate* isolate = object->GetIsolate(); |
| 5171 | 5179 |
| 5172 // TODO(rossberg): Support symbols in the API. | 5180 // TODO(rossberg): Support symbols in the API. |
| 5173 if (name->IsSymbol()) return isolate->factory()->false_value(); | 5181 if (name->IsSymbol()) return isolate->factory()->false_value(); |
| 5174 | 5182 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5301 EnqueueChangeRecord(object, "delete", name, old_value); | 5309 EnqueueChangeRecord(object, "delete", name, old_value); |
| 5302 } | 5310 } |
| 5303 } | 5311 } |
| 5304 | 5312 |
| 5305 return result; | 5313 return result; |
| 5306 } | 5314 } |
| 5307 | 5315 |
| 5308 | 5316 |
| 5309 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5317 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
| 5310 Handle<Name> name, | 5318 Handle<Name> name, |
| 5311 DeleteMode mode) { | 5319 DeleteMode delete_mode) { |
| 5312 Isolate* isolate = object->GetIsolate(); | 5320 Isolate* isolate = object->GetIsolate(); |
| 5313 // ECMA-262, 3rd, 8.6.2.5 | 5321 // ECMA-262, 3rd, 8.6.2.5 |
| 5314 ASSERT(name->IsName()); | 5322 ASSERT(name->IsName()); |
| 5315 | 5323 |
| 5316 // Check access rights if needed. | 5324 // Check access rights if needed. |
| 5317 if (object->IsAccessCheckNeeded() && | 5325 if (object->IsAccessCheckNeeded() && |
| 5318 !isolate->MayNamedAccess(object, name, v8::ACCESS_DELETE)) { | 5326 !isolate->MayNamedAccess(object, name, v8::ACCESS_DELETE)) { |
| 5319 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); | 5327 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); |
| 5320 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5328 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5321 return isolate->factory()->false_value(); | 5329 return isolate->factory()->false_value(); |
| 5322 } | 5330 } |
| 5323 | 5331 |
| 5324 if (object->IsJSGlobalProxy()) { | 5332 if (object->IsJSGlobalProxy()) { |
| 5325 PrototypeIterator iter(isolate, object); | 5333 PrototypeIterator iter(isolate, object); |
| 5326 if (iter.IsAtEnd()) return isolate->factory()->false_value(); | 5334 if (iter.IsAtEnd()) return isolate->factory()->false_value(); |
| 5327 ASSERT(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5335 ASSERT(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
| 5328 return JSGlobalObject::DeleteProperty( | 5336 return JSGlobalObject::DeleteProperty( |
| 5329 Handle<JSGlobalObject>::cast(PrototypeIterator::GetCurrent(iter)), name, | 5337 Handle<JSGlobalObject>::cast(PrototypeIterator::GetCurrent(iter)), name, |
| 5330 mode); | 5338 delete_mode); |
| 5331 } | 5339 } |
| 5332 | 5340 |
| 5333 uint32_t index = 0; | 5341 uint32_t index = 0; |
| 5334 if (name->AsArrayIndex(&index)) { | 5342 if (name->AsArrayIndex(&index)) { |
| 5335 return DeleteElement(object, index, mode); | 5343 return DeleteElement(object, index, delete_mode); |
| 5336 } | 5344 } |
| 5337 | 5345 |
| 5338 LookupResult lookup(isolate); | 5346 LookupResult lookup(isolate); |
| 5339 object->LookupOwn(name, &lookup, true); | 5347 object->LookupOwn(name, &lookup, true); |
| 5340 if (!lookup.IsFound()) return isolate->factory()->true_value(); | 5348 if (!lookup.IsFound()) return isolate->factory()->true_value(); |
| 5341 // Ignore attributes if forcing a deletion. | 5349 // Ignore attributes if forcing a deletion. |
| 5342 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { | 5350 if (lookup.IsDontDelete() && delete_mode != FORCE_DELETION) { |
| 5343 if (mode == STRICT_DELETION) { | 5351 if (delete_mode == STRICT_DELETION) { |
| 5344 // Deleting a non-configurable property in strict mode. | 5352 // Deleting a non-configurable property in strict mode. |
| 5345 Handle<Object> args[2] = { name, object }; | 5353 Handle<Object> args[2] = { name, object }; |
| 5346 Handle<Object> error = isolate->factory()->NewTypeError( | 5354 Handle<Object> error = isolate->factory()->NewTypeError( |
| 5347 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args))); | 5355 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args))); |
| 5348 isolate->Throw(*error); | 5356 isolate->Throw(*error); |
| 5349 return Handle<Object>(); | 5357 return Handle<Object>(); |
| 5350 } | 5358 } |
| 5351 return isolate->factory()->false_value(); | 5359 return isolate->factory()->false_value(); |
| 5352 } | 5360 } |
| 5353 | 5361 |
| 5354 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 5362 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 5355 bool is_observed = object->map()->is_observed() && | 5363 bool is_observed = object->map()->is_observed() && |
| 5356 *name != isolate->heap()->hidden_string(); | 5364 *name != isolate->heap()->hidden_string(); |
| 5357 if (is_observed && lookup.IsDataProperty()) { | 5365 if (is_observed && lookup.IsDataProperty()) { |
| 5358 old_value = Object::GetPropertyOrElement(object, name).ToHandleChecked(); | 5366 old_value = Object::GetPropertyOrElement(object, name).ToHandleChecked(); |
| 5359 } | 5367 } |
| 5360 Handle<Object> result; | 5368 Handle<Object> result; |
| 5361 | 5369 |
| 5362 // Check for interceptor. | 5370 // Check for interceptor. |
| 5363 if (lookup.IsInterceptor()) { | 5371 if (lookup.IsInterceptor()) { |
| 5364 // Skip interceptor if forcing a deletion. | 5372 // Skip interceptor if forcing a deletion. |
| 5365 if (mode == FORCE_DELETION) { | 5373 if (delete_mode == FORCE_DELETION) { |
| 5366 result = DeletePropertyPostInterceptor(object, name, mode); | 5374 result = DeletePropertyPostInterceptor(object, name, delete_mode); |
| 5367 } else { | 5375 } else { |
| 5368 ASSIGN_RETURN_ON_EXCEPTION( | 5376 ASSIGN_RETURN_ON_EXCEPTION( |
| 5369 isolate, result, | 5377 isolate, result, |
| 5370 DeletePropertyWithInterceptor(object, name), | 5378 DeletePropertyWithInterceptor(object, name), |
| 5371 Object); | 5379 Object); |
| 5372 } | 5380 } |
| 5373 } else { | 5381 } else { |
| 5382 PropertyNormalizationMode mode = object->map()->is_prototype_map() | |
| 5383 ? KEEP_INOBJECT_PROPERTIES | |
| 5384 : CLEAR_INOBJECT_PROPERTIES; | |
| 5374 // Normalize object if needed. | 5385 // Normalize object if needed. |
| 5375 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 5386 NormalizeProperties(object, mode, 0); |
| 5376 // Make sure the properties are normalized before removing the entry. | 5387 // Make sure the properties are normalized before removing the entry. |
| 5377 result = DeleteNormalizedProperty(object, name, mode); | 5388 result = DeleteNormalizedProperty(object, name, delete_mode); |
| 5389 ReoptimizeIfPrototype(object); | |
| 5378 } | 5390 } |
| 5379 | 5391 |
| 5380 if (is_observed) { | 5392 if (is_observed) { |
| 5381 Maybe<bool> maybe = HasOwnProperty(object, name); | 5393 Maybe<bool> maybe = HasOwnProperty(object, name); |
| 5382 if (!maybe.has_value) return MaybeHandle<Object>(); | 5394 if (!maybe.has_value) return MaybeHandle<Object>(); |
| 5383 if (!maybe.value) { | 5395 if (!maybe.value) { |
| 5384 EnqueueChangeRecord(object, "delete", name, old_value); | 5396 EnqueueChangeRecord(object, "delete", name, old_value); |
| 5385 } | 5397 } |
| 5386 } | 5398 } |
| 5387 | 5399 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5689 Handle<Map> transition_map(old_map->GetTransition(transition_index)); | 5701 Handle<Map> transition_map(old_map->GetTransition(transition_index)); |
| 5690 ASSERT(transition_map->has_dictionary_elements()); | 5702 ASSERT(transition_map->has_dictionary_elements()); |
| 5691 ASSERT(transition_map->is_frozen()); | 5703 ASSERT(transition_map->is_frozen()); |
| 5692 ASSERT(!transition_map->is_extensible()); | 5704 ASSERT(!transition_map->is_extensible()); |
| 5693 JSObject::MigrateToMap(object, transition_map); | 5705 JSObject::MigrateToMap(object, transition_map); |
| 5694 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { | 5706 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { |
| 5695 // Create a new descriptor array with fully-frozen properties | 5707 // Create a new descriptor array with fully-frozen properties |
| 5696 Handle<Map> new_map = Map::CopyForFreeze(old_map); | 5708 Handle<Map> new_map = Map::CopyForFreeze(old_map); |
| 5697 JSObject::MigrateToMap(object, new_map); | 5709 JSObject::MigrateToMap(object, new_map); |
| 5698 } else { | 5710 } else { |
| 5711 ASSERT(!old_map->is_prototype_map()); | |
|
Igor Sheludko
2014/08/04 13:57:29
I'm afraid that it could fail.
| |
| 5699 // Slow path: need to normalize properties for safety | 5712 // Slow path: need to normalize properties for safety |
| 5700 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 5713 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 5701 | 5714 |
| 5702 // Create a new map, since other objects with this map may be extensible. | 5715 // Create a new map, since other objects with this map may be extensible. |
| 5703 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. | 5716 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. |
| 5704 Handle<Map> new_map = Map::Copy(handle(object->map())); | 5717 Handle<Map> new_map = Map::Copy(handle(object->map())); |
| 5705 new_map->freeze(); | 5718 new_map->freeze(); |
| 5706 new_map->set_is_extensible(false); | 5719 new_map->set_is_extensible(false); |
| 5707 new_map->set_elements_kind(DICTIONARY_ELEMENTS); | 5720 new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
| 5708 JSObject::MigrateToMap(object, new_map); | 5721 JSObject::MigrateToMap(object, new_map); |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6587 heap->ClearAllICsByKind(Code::KEYED_STORE_IC); | 6600 heap->ClearAllICsByKind(Code::KEYED_STORE_IC); |
| 6588 } | 6601 } |
| 6589 } | 6602 } |
| 6590 } | 6603 } |
| 6591 | 6604 |
| 6592 | 6605 |
| 6593 void JSObject::SetPropertyCallback(Handle<JSObject> object, | 6606 void JSObject::SetPropertyCallback(Handle<JSObject> object, |
| 6594 Handle<Name> name, | 6607 Handle<Name> name, |
| 6595 Handle<Object> structure, | 6608 Handle<Object> structure, |
| 6596 PropertyAttributes attributes) { | 6609 PropertyAttributes attributes) { |
| 6610 PropertyNormalizationMode mode = object->map()->is_prototype_map() | |
| 6611 ? KEEP_INOBJECT_PROPERTIES | |
| 6612 : CLEAR_INOBJECT_PROPERTIES; | |
| 6597 // Normalize object to make this operation simple. | 6613 // Normalize object to make this operation simple. |
| 6598 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 6614 NormalizeProperties(object, mode, 0); |
| 6599 | 6615 |
| 6600 // For the global object allocate a new map to invalidate the global inline | 6616 // For the global object allocate a new map to invalidate the global inline |
| 6601 // caches which have a global property cell reference directly in the code. | 6617 // caches which have a global property cell reference directly in the code. |
| 6602 if (object->IsGlobalObject()) { | 6618 if (object->IsGlobalObject()) { |
| 6603 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); | 6619 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); |
| 6604 ASSERT(new_map->is_dictionary_map()); | 6620 ASSERT(new_map->is_dictionary_map()); |
| 6605 JSObject::MigrateToMap(object, new_map); | 6621 JSObject::MigrateToMap(object, new_map); |
| 6606 | 6622 |
| 6607 // When running crankshaft, changing the map is not enough. We | 6623 // When running crankshaft, changing the map is not enough. We |
| 6608 // need to deoptimize all functions that rely on this global | 6624 // need to deoptimize all functions that rely on this global |
| 6609 // object. | 6625 // object. |
| 6610 Deoptimizer::DeoptimizeGlobalObject(*object); | 6626 Deoptimizer::DeoptimizeGlobalObject(*object); |
| 6611 } | 6627 } |
| 6612 | 6628 |
| 6613 // Update the dictionary with the new CALLBACKS property. | 6629 // Update the dictionary with the new CALLBACKS property. |
| 6614 PropertyDetails details = PropertyDetails(attributes, CALLBACKS, 0); | 6630 PropertyDetails details = PropertyDetails(attributes, CALLBACKS, 0); |
| 6615 SetNormalizedProperty(object, name, structure, details); | 6631 SetNormalizedProperty(object, name, structure, details); |
| 6632 | |
| 6633 ReoptimizeIfPrototype(object); | |
| 6616 } | 6634 } |
| 6617 | 6635 |
| 6618 | 6636 |
| 6619 MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object, | 6637 MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object, |
| 6620 Handle<Name> name, | 6638 Handle<Name> name, |
| 6621 Handle<Object> getter, | 6639 Handle<Object> getter, |
| 6622 Handle<Object> setter, | 6640 Handle<Object> setter, |
| 6623 PropertyAttributes attributes) { | 6641 PropertyAttributes attributes) { |
| 6624 Isolate* isolate = object->GetIsolate(); | 6642 Isolate* isolate = object->GetIsolate(); |
| 6625 // Check access rights if needed. | 6643 // Check access rights if needed. |
| (...skipping 3337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9963 if (object->IsGlobalObject()) return; | 9981 if (object->IsGlobalObject()) return; |
| 9964 | 9982 |
| 9965 // Make sure prototypes are fast objects and their maps have the bit set | 9983 // Make sure prototypes are fast objects and their maps have the bit set |
| 9966 // so they remain fast. | 9984 // so they remain fast. |
| 9967 if (!object->HasFastProperties()) { | 9985 if (!object->HasFastProperties()) { |
| 9968 MigrateSlowToFast(object, 0); | 9986 MigrateSlowToFast(object, 0); |
| 9969 } | 9987 } |
| 9970 } | 9988 } |
| 9971 | 9989 |
| 9972 | 9990 |
| 9991 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { | |
| 9992 if (!object->map()->is_prototype_map()) return; | |
| 9993 OptimizeAsPrototype(object); | |
| 9994 } | |
| 9995 | |
| 9996 | |
| 9973 Handle<Object> CacheInitialJSArrayMaps( | 9997 Handle<Object> CacheInitialJSArrayMaps( |
| 9974 Handle<Context> native_context, Handle<Map> initial_map) { | 9998 Handle<Context> native_context, Handle<Map> initial_map) { |
| 9975 // Replace all of the cached initial array maps in the native context with | 9999 // Replace all of the cached initial array maps in the native context with |
| 9976 // the appropriate transitioned elements kind maps. | 10000 // the appropriate transitioned elements kind maps. |
| 9977 Factory* factory = native_context->GetIsolate()->factory(); | 10001 Factory* factory = native_context->GetIsolate()->factory(); |
| 9978 Handle<FixedArray> maps = factory->NewFixedArrayWithHoles( | 10002 Handle<FixedArray> maps = factory->NewFixedArrayWithHoles( |
| 9979 kElementsKindCount, TENURED); | 10003 kElementsKindCount, TENURED); |
| 9980 | 10004 |
| 9981 Handle<Map> current_map = initial_map; | 10005 Handle<Map> current_map = initial_map; |
| 9982 ElementsKind kind = current_map->elements_kind(); | 10006 ElementsKind kind = current_map->elements_kind(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10125 instance_type = JS_OBJECT_TYPE; | 10149 instance_type = JS_OBJECT_TYPE; |
| 10126 instance_size = function->shared()->CalculateInstanceSize(); | 10150 instance_size = function->shared()->CalculateInstanceSize(); |
| 10127 in_object_properties = function->shared()->CalculateInObjectProperties(); | 10151 in_object_properties = function->shared()->CalculateInObjectProperties(); |
| 10128 } | 10152 } |
| 10129 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); | 10153 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); |
| 10130 | 10154 |
| 10131 // Fetch or allocate prototype. | 10155 // Fetch or allocate prototype. |
| 10132 Handle<Object> prototype; | 10156 Handle<Object> prototype; |
| 10133 if (function->has_instance_prototype()) { | 10157 if (function->has_instance_prototype()) { |
| 10134 prototype = handle(function->instance_prototype(), isolate); | 10158 prototype = handle(function->instance_prototype(), isolate); |
| 10135 // TODO(verwaest): Remove once "delete" keeps objects marked as prototypes | |
| 10136 // fast as well. | |
| 10137 JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(prototype)); | |
| 10138 } else { | 10159 } else { |
| 10139 prototype = isolate->factory()->NewFunctionPrototype(function); | 10160 prototype = isolate->factory()->NewFunctionPrototype(function); |
| 10140 } | 10161 } |
| 10141 map->set_inobject_properties(in_object_properties); | 10162 map->set_inobject_properties(in_object_properties); |
| 10142 map->set_unused_property_fields(in_object_properties); | 10163 map->set_unused_property_fields(in_object_properties); |
| 10143 map->set_prototype(*prototype); | 10164 map->set_prototype(*prototype); |
| 10144 ASSERT(map->has_fast_object_elements()); | 10165 ASSERT(map->has_fast_object_elements()); |
| 10145 | 10166 |
| 10146 // Finally link initial map and constructor function. | 10167 // Finally link initial map and constructor function. |
| 10147 function->set_initial_map(*map); | 10168 function->set_initial_map(*map); |
| (...skipping 6876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17024 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17045 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17025 static const char* error_messages_[] = { | 17046 static const char* error_messages_[] = { |
| 17026 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17047 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17027 }; | 17048 }; |
| 17028 #undef ERROR_MESSAGES_TEXTS | 17049 #undef ERROR_MESSAGES_TEXTS |
| 17029 return error_messages_[reason]; | 17050 return error_messages_[reason]; |
| 17030 } | 17051 } |
| 17031 | 17052 |
| 17032 | 17053 |
| 17033 } } // namespace v8::internal | 17054 } } // namespace v8::internal |
| OLD | NEW |