OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 result->holder()->LookupRealNamedProperty(*name, &r); | 663 result->holder()->LookupRealNamedProperty(*name, &r); |
664 } else { | 664 } else { |
665 result->holder()->LocalLookupRealNamedProperty(*name, &r); | 665 result->holder()->LocalLookupRealNamedProperty(*name, &r); |
666 } | 666 } |
667 if (!r.IsFound()) break; | 667 if (!r.IsFound()) break; |
668 return GetPropertyAttributeWithFailedAccessCheck( | 668 return GetPropertyAttributeWithFailedAccessCheck( |
669 object, &r, name, continue_search); | 669 object, &r, name, continue_search); |
670 } | 670 } |
671 | 671 |
672 case HANDLER: | 672 case HANDLER: |
673 case TRANSITION: | |
674 case NONEXISTENT: | 673 case NONEXISTENT: |
675 UNREACHABLE(); | 674 UNREACHABLE(); |
676 } | 675 } |
677 } | 676 } |
678 | 677 |
679 object->GetIsolate()->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 678 object->GetIsolate()->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
680 return ABSENT; | 679 return ABSENT; |
681 } | 680 } |
682 | 681 |
683 | 682 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 case INTERCEPTOR: { | 936 case INTERCEPTOR: { |
938 HandleScope scope(isolate); | 937 HandleScope scope(isolate); |
939 Handle<Object> value = JSObject::GetPropertyWithInterceptor( | 938 Handle<Object> value = JSObject::GetPropertyWithInterceptor( |
940 handle(result->holder(), isolate), | 939 handle(result->holder(), isolate), |
941 handle(receiver, isolate), | 940 handle(receiver, isolate), |
942 handle(name, isolate), | 941 handle(name, isolate), |
943 attributes); | 942 attributes); |
944 RETURN_IF_EMPTY_HANDLE(isolate, value); | 943 RETURN_IF_EMPTY_HANDLE(isolate, value); |
945 return *value; | 944 return *value; |
946 } | 945 } |
947 case TRANSITION: | |
948 case NONEXISTENT: | 946 case NONEXISTENT: |
949 UNREACHABLE(); | 947 UNREACHABLE(); |
950 break; | 948 break; |
951 } | 949 } |
952 UNREACHABLE(); | 950 UNREACHABLE(); |
953 return NULL; | 951 return NULL; |
954 } | 952 } |
955 | 953 |
956 | 954 |
957 Handle<Object> Object::GetElementWithReceiver(Isolate* isolate, | 955 Handle<Object> Object::GetElementWithReceiver(Isolate* isolate, |
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3070 *done = true; | 3068 *done = true; |
3071 Handle<Object> callback_object(result.GetCallbackObject(), isolate); | 3069 Handle<Object> callback_object(result.GetCallbackObject(), isolate); |
3072 return SetPropertyWithCallback(object, callback_object, name, value, | 3070 return SetPropertyWithCallback(object, callback_object, name, value, |
3073 handle(result.holder()), strict_mode); | 3071 handle(result.holder()), strict_mode); |
3074 } | 3072 } |
3075 case HANDLER: { | 3073 case HANDLER: { |
3076 Handle<JSProxy> proxy(result.proxy()); | 3074 Handle<JSProxy> proxy(result.proxy()); |
3077 return JSProxy::SetPropertyViaPrototypesWithHandler( | 3075 return JSProxy::SetPropertyViaPrototypesWithHandler( |
3078 proxy, object, name, value, attributes, strict_mode, done); | 3076 proxy, object, name, value, attributes, strict_mode, done); |
3079 } | 3077 } |
3080 case TRANSITION: | |
3081 case NONEXISTENT: | 3078 case NONEXISTENT: |
3082 UNREACHABLE(); | 3079 UNREACHABLE(); |
3083 break; | 3080 break; |
3084 } | 3081 } |
3085 } | 3082 } |
3086 | 3083 |
3087 // If we get here with *done true, we have encountered a read-only property. | 3084 // If we get here with *done true, we have encountered a read-only property. |
3088 if (*done) { | 3085 if (*done) { |
3089 if (strict_mode == SLOPPY) return value; | 3086 if (strict_mode == SLOPPY) return value; |
3090 Handle<Object> args[] = { name, object }; | 3087 Handle<Object> args[] = { name, object }; |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3908 return JSObject::AddProperty( | 3905 return JSObject::AddProperty( |
3909 object, name, value, attributes, SLOPPY, | 3906 object, name, value, attributes, SLOPPY, |
3910 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED, | 3907 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED, |
3911 JSReceiver::OMIT_EXTENSIBILITY_CHECK, | 3908 JSReceiver::OMIT_EXTENSIBILITY_CHECK, |
3912 JSObject::FORCE_TAGGED, FORCE_FIELD, OMIT_TRANSITION); | 3909 JSObject::FORCE_TAGGED, FORCE_FIELD, OMIT_TRANSITION); |
3913 } | 3910 } |
3914 | 3911 |
3915 // Keep the target CONSTANT if the same value is stored. | 3912 // Keep the target CONSTANT if the same value is stored. |
3916 // TODO(verwaest): Also support keeping the placeholder | 3913 // TODO(verwaest): Also support keeping the placeholder |
3917 // (value->IsUninitialized) as constant. | 3914 // (value->IsUninitialized) as constant. |
3918 if (!value->FitsRepresentation(details.representation()) || | 3915 if (!lookup->CanHoldValue(value) || |
3919 (details.type() == CONSTANT && | 3916 (details.type() == CONSTANT && |
3920 descriptors->GetValue(descriptor) != *value)) { | 3917 descriptors->GetValue(descriptor) != *value)) { |
3921 transition_map = Map::GeneralizeRepresentation(transition_map, | 3918 transition_map = Map::GeneralizeRepresentation(transition_map, |
3922 descriptor, value->OptimalRepresentation(), FORCE_FIELD); | 3919 descriptor, value->OptimalRepresentation(), FORCE_FIELD); |
3923 } | 3920 } |
3924 | 3921 |
3925 JSObject::MigrateToMap(object, transition_map); | 3922 JSObject::MigrateToMap(object, transition_map); |
3926 | 3923 |
3927 // Reload. | 3924 // Reload. |
3928 descriptors = transition_map->instance_descriptors(); | 3925 descriptors = transition_map->instance_descriptors(); |
(...skipping 12 matching lines...) Expand all Loading... |
3941 } | 3938 } |
3942 | 3939 |
3943 return value; | 3940 return value; |
3944 } | 3941 } |
3945 | 3942 |
3946 | 3943 |
3947 static void SetPropertyToField(LookupResult* lookup, | 3944 static void SetPropertyToField(LookupResult* lookup, |
3948 Handle<Name> name, | 3945 Handle<Name> name, |
3949 Handle<Object> value) { | 3946 Handle<Object> value) { |
3950 Representation representation = lookup->representation(); | 3947 Representation representation = lookup->representation(); |
3951 if (!value->FitsRepresentation(representation) || | 3948 if (!lookup->CanHoldValue(value) || |
3952 lookup->type() == CONSTANT) { | 3949 lookup->type() == CONSTANT) { |
3953 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()), | 3950 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()), |
3954 lookup->GetDescriptorIndex(), | 3951 lookup->GetDescriptorIndex(), |
3955 value->OptimalRepresentation(), | 3952 value->OptimalRepresentation(), |
3956 FORCE_FIELD); | 3953 FORCE_FIELD); |
3957 DescriptorArray* desc = lookup->holder()->map()->instance_descriptors(); | 3954 DescriptorArray* desc = lookup->holder()->map()->instance_descriptors(); |
3958 int descriptor = lookup->GetDescriptorIndex(); | 3955 int descriptor = lookup->GetDescriptorIndex(); |
3959 representation = desc->GetDetails(descriptor).representation(); | 3956 representation = desc->GetDetails(descriptor).representation(); |
3960 } | 3957 } |
3961 | 3958 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4084 bool is_observed = object->map()->is_observed() && | 4081 bool is_observed = object->map()->is_observed() && |
4085 *name != isolate->heap()->hidden_string(); | 4082 *name != isolate->heap()->hidden_string(); |
4086 if (is_observed && lookup->IsDataProperty()) { | 4083 if (is_observed && lookup->IsDataProperty()) { |
4087 old_value = Object::GetPropertyOrElement(object, name); | 4084 old_value = Object::GetPropertyOrElement(object, name); |
4088 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); | 4085 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); |
4089 } | 4086 } |
4090 | 4087 |
4091 // This is a real property that is not read-only, or it is a | 4088 // This is a real property that is not read-only, or it is a |
4092 // transition or null descriptor and there are no setters in the prototypes. | 4089 // transition or null descriptor and there are no setters in the prototypes. |
4093 Handle<Object> result = value; | 4090 Handle<Object> result = value; |
4094 switch (lookup->type()) { | 4091 if (lookup->IsTransition()) { |
4095 case NORMAL: | 4092 result = SetPropertyUsingTransition(handle(lookup->holder()), lookup, |
4096 SetNormalizedProperty(handle(lookup->holder()), lookup, value); | 4093 name, value, attributes); |
4097 break; | 4094 } else { |
4098 case FIELD: | 4095 switch (lookup->type()) { |
4099 SetPropertyToField(lookup, name, value); | 4096 case NORMAL: |
4100 break; | 4097 SetNormalizedProperty(handle(lookup->holder()), lookup, value); |
4101 case CONSTANT: | 4098 break; |
4102 // Only replace the constant if necessary. | 4099 case FIELD: |
4103 if (*value == lookup->GetConstant()) return value; | 4100 SetPropertyToField(lookup, name, value); |
4104 SetPropertyToField(lookup, name, value); | 4101 break; |
4105 break; | 4102 case CONSTANT: |
4106 case CALLBACKS: { | 4103 // Only replace the constant if necessary. |
4107 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate); | 4104 if (*value == lookup->GetConstant()) return value; |
4108 return SetPropertyWithCallback(object, callback_object, name, value, | 4105 SetPropertyToField(lookup, name, value); |
4109 handle(lookup->holder()), strict_mode); | 4106 break; |
| 4107 case CALLBACKS: { |
| 4108 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate); |
| 4109 return SetPropertyWithCallback(object, callback_object, name, value, |
| 4110 handle(lookup->holder()), strict_mode); |
| 4111 } |
| 4112 case INTERCEPTOR: |
| 4113 result = SetPropertyWithInterceptor( |
| 4114 handle(lookup->holder()), name, value, attributes, strict_mode); |
| 4115 break; |
| 4116 case HANDLER: |
| 4117 case NONEXISTENT: |
| 4118 UNREACHABLE(); |
4110 } | 4119 } |
4111 case INTERCEPTOR: | |
4112 result = SetPropertyWithInterceptor(handle(lookup->holder()), name, value, | |
4113 attributes, strict_mode); | |
4114 break; | |
4115 case TRANSITION: | |
4116 result = SetPropertyUsingTransition(handle(lookup->holder()), lookup, | |
4117 name, value, attributes); | |
4118 break; | |
4119 case HANDLER: | |
4120 case NONEXISTENT: | |
4121 UNREACHABLE(); | |
4122 } | 4120 } |
4123 | 4121 |
4124 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); | 4122 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); |
4125 | 4123 |
4126 if (is_observed) { | 4124 if (is_observed) { |
4127 if (lookup->IsTransition()) { | 4125 if (lookup->IsTransition()) { |
4128 EnqueueChangeRecord(object, "add", name, old_value); | 4126 EnqueueChangeRecord(object, "add", name, old_value); |
4129 } else { | 4127 } else { |
4130 LookupResult new_lookup(isolate); | 4128 LookupResult new_lookup(isolate); |
4131 object->LocalLookup(*name, &new_lookup, true); | 4129 object->LocalLookup(*name, &new_lookup, true); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4209 *name != isolate->heap()->hidden_string(); | 4207 *name != isolate->heap()->hidden_string(); |
4210 if (is_observed && lookup.IsProperty()) { | 4208 if (is_observed && lookup.IsProperty()) { |
4211 if (lookup.IsDataProperty()) { | 4209 if (lookup.IsDataProperty()) { |
4212 old_value = Object::GetPropertyOrElement(object, name); | 4210 old_value = Object::GetPropertyOrElement(object, name); |
4213 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); | 4211 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); |
4214 } | 4212 } |
4215 old_attributes = lookup.GetAttributes(); | 4213 old_attributes = lookup.GetAttributes(); |
4216 } | 4214 } |
4217 | 4215 |
4218 // Check of IsReadOnly removed from here in clone. | 4216 // Check of IsReadOnly removed from here in clone. |
4219 switch (lookup.type()) { | 4217 if (lookup.IsTransition()) { |
4220 case NORMAL: | 4218 Handle<Object> result = SetPropertyUsingTransition( |
4221 ReplaceSlowProperty(object, name, value, attributes); | 4219 handle(lookup.holder()), &lookup, name, value, attributes); |
4222 break; | 4220 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); |
4223 case FIELD: | 4221 } else { |
4224 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); | 4222 switch (lookup.type()) { |
4225 break; | 4223 case NORMAL: |
4226 case CONSTANT: | 4224 ReplaceSlowProperty(object, name, value, attributes); |
4227 // Only replace the constant if necessary. | 4225 break; |
4228 if (lookup.GetAttributes() != attributes || | 4226 case FIELD: |
4229 *value != lookup.GetConstant()) { | |
4230 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); | 4227 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); |
4231 } | 4228 break; |
4232 break; | 4229 case CONSTANT: |
4233 case CALLBACKS: | 4230 // Only replace the constant if necessary. |
4234 ConvertAndSetLocalProperty(&lookup, name, value, attributes); | 4231 if (lookup.GetAttributes() != attributes || |
4235 break; | 4232 *value != lookup.GetConstant()) { |
4236 case TRANSITION: { | 4233 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); |
4237 Handle<Object> result = SetPropertyUsingTransition( | 4234 } |
4238 handle(lookup.holder()), &lookup, name, value, attributes); | 4235 break; |
4239 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); | 4236 case CALLBACKS: |
4240 break; | 4237 ConvertAndSetLocalProperty(&lookup, name, value, attributes); |
| 4238 break; |
| 4239 case NONEXISTENT: |
| 4240 case HANDLER: |
| 4241 case INTERCEPTOR: |
| 4242 UNREACHABLE(); |
4241 } | 4243 } |
4242 case NONEXISTENT: | |
4243 case HANDLER: | |
4244 case INTERCEPTOR: | |
4245 UNREACHABLE(); | |
4246 } | 4244 } |
4247 | 4245 |
4248 if (is_observed) { | 4246 if (is_observed) { |
4249 if (lookup.IsTransition()) { | 4247 if (lookup.IsTransition()) { |
4250 EnqueueChangeRecord(object, "add", name, old_value); | 4248 EnqueueChangeRecord(object, "add", name, old_value); |
4251 } else if (old_value->IsTheHole()) { | 4249 } else if (old_value->IsTheHole()) { |
4252 EnqueueChangeRecord(object, "reconfigure", name, old_value); | 4250 EnqueueChangeRecord(object, "reconfigure", name, old_value); |
4253 } else { | 4251 } else { |
4254 LookupResult new_lookup(isolate); | 4252 LookupResult new_lookup(isolate); |
4255 object->LocalLookup(*name, &new_lookup, true); | 4253 object->LocalLookup(*name, &new_lookup, true); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4379 case HANDLER: { | 4377 case HANDLER: { |
4380 return JSProxy::GetPropertyAttributeWithHandler( | 4378 return JSProxy::GetPropertyAttributeWithHandler( |
4381 handle(lookup->proxy()), receiver, name); | 4379 handle(lookup->proxy()), receiver, name); |
4382 } | 4380 } |
4383 case INTERCEPTOR: | 4381 case INTERCEPTOR: |
4384 return JSObject::GetPropertyAttributeWithInterceptor( | 4382 return JSObject::GetPropertyAttributeWithInterceptor( |
4385 handle(lookup->holder()), | 4383 handle(lookup->holder()), |
4386 Handle<JSObject>::cast(receiver), | 4384 Handle<JSObject>::cast(receiver), |
4387 name, | 4385 name, |
4388 continue_search); | 4386 continue_search); |
4389 case TRANSITION: | |
4390 case NONEXISTENT: | 4387 case NONEXISTENT: |
4391 UNREACHABLE(); | 4388 UNREACHABLE(); |
4392 } | 4389 } |
4393 } | 4390 } |
4394 return ABSENT; | 4391 return ABSENT; |
4395 } | 4392 } |
4396 | 4393 |
4397 | 4394 |
4398 PropertyAttributes JSReceiver::GetLocalPropertyAttribute( | 4395 PropertyAttributes JSReceiver::GetLocalPropertyAttribute( |
4399 Handle<JSReceiver> object, Handle<Name> name) { | 4396 Handle<JSReceiver> object, Handle<Name> name) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4622 Handle<Object> value(descs->GetCallbacksObject(i), isolate); | 4619 Handle<Object> value(descs->GetCallbacksObject(i), isolate); |
4623 PropertyDetails d = PropertyDetails( | 4620 PropertyDetails d = PropertyDetails( |
4624 details.attributes(), CALLBACKS, i + 1); | 4621 details.attributes(), CALLBACKS, i + 1); |
4625 dictionary = NameDictionaryAdd(dictionary, key, value, d); | 4622 dictionary = NameDictionaryAdd(dictionary, key, value, d); |
4626 break; | 4623 break; |
4627 } | 4624 } |
4628 case INTERCEPTOR: | 4625 case INTERCEPTOR: |
4629 break; | 4626 break; |
4630 case HANDLER: | 4627 case HANDLER: |
4631 case NORMAL: | 4628 case NORMAL: |
4632 case TRANSITION: | |
4633 case NONEXISTENT: | 4629 case NONEXISTENT: |
4634 UNREACHABLE(); | 4630 UNREACHABLE(); |
4635 break; | 4631 break; |
4636 } | 4632 } |
4637 } | 4633 } |
4638 | 4634 |
4639 // Copy the next enumeration index from instance descriptor. | 4635 // Copy the next enumeration index from instance descriptor. |
4640 dictionary->SetNextEnumerationIndex(real_size + 1); | 4636 dictionary->SetNextEnumerationIndex(real_size + 1); |
4641 | 4637 |
4642 Handle<NormalizedMapCache> cache( | 4638 Handle<NormalizedMapCache> cache( |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5569 // unnecessary transitions. | 5565 // unnecessary transitions. |
5570 new_element_dictionary = CopyFastElementsToDictionary( | 5566 new_element_dictionary = CopyFastElementsToDictionary( |
5571 handle(object->elements()), length, new_element_dictionary); | 5567 handle(object->elements()), length, new_element_dictionary); |
5572 } else { | 5568 } else { |
5573 // No existing elements, use a pre-allocated empty backing store | 5569 // No existing elements, use a pre-allocated empty backing store |
5574 new_element_dictionary = | 5570 new_element_dictionary = |
5575 isolate->factory()->empty_slow_element_dictionary(); | 5571 isolate->factory()->empty_slow_element_dictionary(); |
5576 } | 5572 } |
5577 } | 5573 } |
5578 | 5574 |
5579 LookupResult result(isolate); | 5575 Handle<Map> old_map(object->map(), isolate); |
5580 Handle<Map> old_map(object->map()); | 5576 int transition_index = old_map->SearchTransition( |
5581 old_map->LookupTransition(*object, isolate->heap()->frozen_symbol(), &result); | 5577 isolate->heap()->frozen_symbol()); |
5582 if (result.IsTransition()) { | 5578 if (transition_index != TransitionArray::kNotFound) { |
5583 Handle<Map> transition_map(result.GetTransitionTarget()); | 5579 Handle<Map> transition_map(old_map->GetTransition(transition_index)); |
5584 ASSERT(transition_map->has_dictionary_elements()); | 5580 ASSERT(transition_map->has_dictionary_elements()); |
5585 ASSERT(transition_map->is_frozen()); | 5581 ASSERT(transition_map->is_frozen()); |
5586 ASSERT(!transition_map->is_extensible()); | 5582 ASSERT(!transition_map->is_extensible()); |
5587 JSObject::MigrateToMap(object, transition_map); | 5583 JSObject::MigrateToMap(object, transition_map); |
5588 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { | 5584 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { |
5589 // Create a new descriptor array with fully-frozen properties | 5585 // Create a new descriptor array with fully-frozen properties |
5590 int num_descriptors = old_map->NumberOfOwnDescriptors(); | 5586 int num_descriptors = old_map->NumberOfOwnDescriptors(); |
5591 Handle<DescriptorArray> new_descriptors = | 5587 Handle<DescriptorArray> new_descriptors = |
5592 DescriptorArray::CopyUpToAddAttributes( | 5588 DescriptorArray::CopyUpToAddAttributes( |
5593 handle(old_map->instance_descriptors()), num_descriptors, FROZEN); | 5589 handle(old_map->instance_descriptors()), num_descriptors, FROZEN); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5625 dictionary->set_requires_slow_elements(); | 5621 dictionary->set_requires_slow_elements(); |
5626 // Freeze all elements in the dictionary | 5622 // Freeze all elements in the dictionary |
5627 FreezeDictionary(dictionary); | 5623 FreezeDictionary(dictionary); |
5628 } | 5624 } |
5629 | 5625 |
5630 return object; | 5626 return object; |
5631 } | 5627 } |
5632 | 5628 |
5633 | 5629 |
5634 void JSObject::SetObserved(Handle<JSObject> object) { | 5630 void JSObject::SetObserved(Handle<JSObject> object) { |
5635 ASSERT(!object->map()->is_observed()); | |
5636 Isolate* isolate = object->GetIsolate(); | 5631 Isolate* isolate = object->GetIsolate(); |
5637 | |
5638 LookupResult result(isolate); | |
5639 object->map()->LookupTransition(*object, | |
5640 isolate->heap()->observed_symbol(), | |
5641 &result); | |
5642 | |
5643 Handle<Map> new_map; | 5632 Handle<Map> new_map; |
5644 if (result.IsTransition()) { | 5633 Handle<Map> old_map(object->map(), isolate); |
5645 new_map = handle(result.GetTransitionTarget()); | 5634 ASSERT(!old_map->is_observed()); |
| 5635 int transition_index = old_map->SearchTransition( |
| 5636 isolate->heap()->observed_symbol()); |
| 5637 if (transition_index != TransitionArray::kNotFound) { |
| 5638 new_map = handle(old_map->GetTransition(transition_index), isolate); |
5646 ASSERT(new_map->is_observed()); | 5639 ASSERT(new_map->is_observed()); |
5647 } else if (object->map()->CanHaveMoreTransitions()) { | 5640 } else if (old_map->CanHaveMoreTransitions()) { |
5648 new_map = Map::CopyForObserved(handle(object->map())); | 5641 new_map = Map::CopyForObserved(old_map); |
5649 } else { | 5642 } else { |
5650 new_map = Map::Copy(handle(object->map())); | 5643 new_map = Map::Copy(old_map); |
5651 new_map->set_is_observed(); | 5644 new_map->set_is_observed(); |
5652 } | 5645 } |
5653 JSObject::MigrateToMap(object, new_map); | 5646 JSObject::MigrateToMap(object, new_map); |
5654 } | 5647 } |
5655 | 5648 |
5656 | 5649 |
5657 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) { | 5650 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) { |
5658 Isolate* isolate = object->GetIsolate(); | 5651 Isolate* isolate = object->GetIsolate(); |
5659 CALL_HEAP_FUNCTION(isolate, | 5652 CALL_HEAP_FUNCTION(isolate, |
5660 isolate->heap()->CopyJSObject(*object), JSObject); | 5653 isolate->heap()->CopyJSObject(*object), JSObject); |
(...skipping 10794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16455 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16448 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16456 static const char* error_messages_[] = { | 16449 static const char* error_messages_[] = { |
16457 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16450 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16458 }; | 16451 }; |
16459 #undef ERROR_MESSAGES_TEXTS | 16452 #undef ERROR_MESSAGES_TEXTS |
16460 return error_messages_[reason]; | 16453 return error_messages_[reason]; |
16461 } | 16454 } |
16462 | 16455 |
16463 | 16456 |
16464 } } // namespace v8::internal | 16457 } } // namespace v8::internal |
OLD | NEW |