OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2913 } | 2913 } |
2914 | 2914 |
2915 if (IsJSGlobalProxy()) { | 2915 if (IsJSGlobalProxy()) { |
2916 Object* proto = GetPrototype(); | 2916 Object* proto = GetPrototype(); |
2917 if (proto->IsNull()) return value_raw; | 2917 if (proto->IsNull()) return value_raw; |
2918 ASSERT(proto->IsJSGlobalObject()); | 2918 ASSERT(proto->IsJSGlobalObject()); |
2919 return JSObject::cast(proto)->SetPropertyForResult( | 2919 return JSObject::cast(proto)->SetPropertyForResult( |
2920 lookup, name_raw, value_raw, attributes, strict_mode, store_mode); | 2920 lookup, name_raw, value_raw, attributes, strict_mode, store_mode); |
2921 } | 2921 } |
2922 | 2922 |
| 2923 ASSERT(!lookup->IsFound() || lookup->holder() == this || |
| 2924 lookup->holder()->map()->is_hidden_prototype()); |
| 2925 |
2923 // From this point on everything needs to be handlified, because | 2926 // From this point on everything needs to be handlified, because |
2924 // SetPropertyViaPrototypes might call back into JavaScript. | 2927 // SetPropertyViaPrototypes might call back into JavaScript. |
2925 HandleScope scope(isolate); | 2928 HandleScope scope(isolate); |
2926 Handle<JSObject> self(this); | 2929 Handle<JSObject> self(this); |
2927 Handle<String> name(name_raw); | 2930 Handle<String> name(name_raw); |
2928 Handle<Object> value(value_raw, isolate); | 2931 Handle<Object> value(value_raw, isolate); |
2929 | 2932 |
2930 if (!lookup->IsProperty() && !self->IsJSContextExtensionObject()) { | 2933 if (!lookup->IsProperty() && !self->IsJSContextExtensionObject()) { |
2931 bool done = false; | 2934 bool done = false; |
2932 MaybeObject* result_object = self->SetPropertyViaPrototypes( | 2935 MaybeObject* result_object = self->SetPropertyViaPrototypes( |
(...skipping 21 matching lines...) Expand all Loading... |
2954 if (FLAG_harmony_observation && | 2957 if (FLAG_harmony_observation && |
2955 map()->is_observed() && lookup->IsDataProperty()) { | 2958 map()->is_observed() && lookup->IsDataProperty()) { |
2956 old_value = Object::GetProperty(self, name); | 2959 old_value = Object::GetProperty(self, name); |
2957 } | 2960 } |
2958 | 2961 |
2959 // This is a real property that is not read-only, or it is a | 2962 // This is a real property that is not read-only, or it is a |
2960 // transition or null descriptor and there are no setters in the prototypes. | 2963 // transition or null descriptor and there are no setters in the prototypes. |
2961 MaybeObject* result = *value; | 2964 MaybeObject* result = *value; |
2962 switch (lookup->type()) { | 2965 switch (lookup->type()) { |
2963 case NORMAL: | 2966 case NORMAL: |
2964 result = self->SetNormalizedProperty(lookup, *value); | 2967 result = lookup->holder()->SetNormalizedProperty(lookup, *value); |
2965 break; | 2968 break; |
2966 case FIELD: | 2969 case FIELD: |
2967 result = self->FastPropertyAtPut( | 2970 result = lookup->holder()->FastPropertyAtPut( |
2968 lookup->GetFieldIndex().field_index(), *value); | 2971 lookup->GetFieldIndex().field_index(), *value); |
2969 break; | 2972 break; |
2970 case CONSTANT_FUNCTION: | 2973 case CONSTANT_FUNCTION: |
2971 // Only replace the function if necessary. | 2974 // Only replace the function if necessary. |
2972 if (*value == lookup->GetConstantFunction()) return *value; | 2975 if (*value == lookup->GetConstantFunction()) return *value; |
2973 // Preserve the attributes of this existing property. | 2976 // Preserve the attributes of this existing property. |
2974 attributes = lookup->GetAttributes(); | 2977 attributes = lookup->GetAttributes(); |
2975 result = self->ConvertDescriptorToField(*name, *value, attributes); | 2978 result = |
| 2979 lookup->holder()->ConvertDescriptorToField(*name, *value, attributes); |
2976 break; | 2980 break; |
2977 case CALLBACKS: { | 2981 case CALLBACKS: { |
2978 Object* callback_object = lookup->GetCallbackObject(); | 2982 Object* callback_object = lookup->GetCallbackObject(); |
2979 return self->SetPropertyWithCallback(callback_object, | 2983 return self->SetPropertyWithCallback( |
2980 *name, | 2984 callback_object, *name, *value, lookup->holder(), strict_mode); |
2981 *value, | |
2982 lookup->holder(), | |
2983 strict_mode); | |
2984 } | 2985 } |
2985 case INTERCEPTOR: | 2986 case INTERCEPTOR: |
2986 result = self->SetPropertyWithInterceptor(*name, | 2987 result = lookup->holder()->SetPropertyWithInterceptor( |
2987 *value, | 2988 *name, *value, attributes, strict_mode); |
2988 attributes, | |
2989 strict_mode); | |
2990 break; | 2989 break; |
2991 case TRANSITION: { | 2990 case TRANSITION: { |
2992 Map* transition_map = lookup->GetTransitionTarget(); | 2991 Map* transition_map = lookup->GetTransitionTarget(); |
2993 int descriptor = transition_map->LastAdded(); | 2992 int descriptor = transition_map->LastAdded(); |
2994 | 2993 |
2995 DescriptorArray* descriptors = transition_map->instance_descriptors(); | 2994 DescriptorArray* descriptors = transition_map->instance_descriptors(); |
2996 PropertyDetails details = descriptors->GetDetails(descriptor); | 2995 PropertyDetails details = descriptors->GetDetails(descriptor); |
2997 | 2996 |
2998 if (details.type() == FIELD) { | 2997 if (details.type() == FIELD) { |
2999 if (attributes == details.attributes()) { | 2998 if (attributes == details.attributes()) { |
3000 int field_index = descriptors->GetFieldIndex(descriptor); | 2999 int field_index = descriptors->GetFieldIndex(descriptor); |
3001 result = self->AddFastPropertyUsingMap(transition_map, | 3000 result = lookup->holder()->AddFastPropertyUsingMap( |
3002 *name, | 3001 transition_map, *name, *value, field_index); |
3003 *value, | |
3004 field_index); | |
3005 } else { | 3002 } else { |
3006 result = self->ConvertDescriptorToField(*name, *value, attributes); | 3003 result = lookup->holder()->ConvertDescriptorToField( |
| 3004 *name, *value, attributes); |
3007 } | 3005 } |
3008 } else if (details.type() == CALLBACKS) { | 3006 } else if (details.type() == CALLBACKS) { |
3009 result = self->ConvertDescriptorToField(*name, *value, attributes); | 3007 result = lookup->holder()->ConvertDescriptorToField( |
| 3008 *name, *value, attributes); |
3010 } else { | 3009 } else { |
3011 ASSERT(details.type() == CONSTANT_FUNCTION); | 3010 ASSERT(details.type() == CONSTANT_FUNCTION); |
3012 | 3011 |
3013 Object* constant_function = descriptors->GetValue(descriptor); | 3012 Object* constant_function = descriptors->GetValue(descriptor); |
3014 if (constant_function == *value) { | 3013 if (constant_function == *value) { |
3015 // If the same constant function is being added we can simply | 3014 // If the same constant function is being added we can simply |
3016 // transition to the target map. | 3015 // transition to the target map. |
3017 self->set_map(transition_map); | 3016 lookup->holder()->set_map(transition_map); |
3018 result = constant_function; | 3017 result = constant_function; |
3019 } else { | 3018 } else { |
3020 // Otherwise, replace with a map transition to a new map with a FIELD, | 3019 // Otherwise, replace with a map transition to a new map with a FIELD, |
3021 // even if the value is a constant function. | 3020 // even if the value is a constant function. |
3022 result = self->ConvertTransitionToMapTransition( | 3021 result = lookup->holder()->ConvertTransitionToMapTransition( |
3023 lookup->GetTransitionIndex(), *name, *value, attributes); | 3022 lookup->GetTransitionIndex(), *name, *value, attributes); |
3024 } | 3023 } |
3025 } | 3024 } |
3026 break; | 3025 break; |
3027 } | 3026 } |
3028 case HANDLER: | 3027 case HANDLER: |
3029 case NONEXISTENT: | 3028 case NONEXISTENT: |
3030 UNREACHABLE(); | 3029 UNREACHABLE(); |
3031 } | 3030 } |
3032 | 3031 |
(...skipping 11009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14042 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14041 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
14043 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14042 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
14044 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14043 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
14045 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14044 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
14046 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14045 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
14047 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14046 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
14048 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14047 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
14049 } | 14048 } |
14050 | 14049 |
14051 } } // namespace v8::internal | 14050 } } // namespace v8::internal |
OLD | NEW |