Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/objects.cc

Issue 992913002: handle the special snowflakes that are Integer Indexed Exotic objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/lookup-inl.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (it->isolate()->has_pending_exception()) return maybe_result; 126 if (it->isolate()->has_pending_exception()) return maybe_result;
127 break; 127 break;
128 } 128 }
129 case LookupIterator::ACCESS_CHECK: 129 case LookupIterator::ACCESS_CHECK:
130 if (it->HasAccess()) break; 130 if (it->HasAccess()) break;
131 return JSObject::GetPropertyWithFailedAccessCheck(it); 131 return JSObject::GetPropertyWithFailedAccessCheck(it);
132 case LookupIterator::ACCESSOR: 132 case LookupIterator::ACCESSOR:
133 return GetPropertyWithAccessor(it->GetReceiver(), it->name(), 133 return GetPropertyWithAccessor(it->GetReceiver(), it->name(),
134 it->GetHolder<JSObject>(), 134 it->GetHolder<JSObject>(),
135 it->GetAccessors()); 135 it->GetAccessors());
136 case LookupIterator::INTEGER_INDEXED_EXOTIC:
137 return it->factory()->undefined_value();
136 case LookupIterator::DATA: 138 case LookupIterator::DATA:
137 return it->GetDataValue(); 139 return it->GetDataValue();
138 } 140 }
139 } 141 }
140 return it->factory()->undefined_value(); 142 return it->factory()->undefined_value();
141 } 143 }
142 144
143 145
144 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object, 146 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
145 Handle<Name> key) { 147 Handle<Name> key) {
(...skipping 15 matching lines...) Expand all
161 // Fall through. 163 // Fall through.
162 case LookupIterator::JSPROXY: 164 case LookupIterator::JSPROXY:
163 it->NotFound(); 165 it->NotFound();
164 return it->isolate()->factory()->undefined_value(); 166 return it->isolate()->factory()->undefined_value();
165 case LookupIterator::ACCESSOR: 167 case LookupIterator::ACCESSOR:
166 // TODO(verwaest): For now this doesn't call into 168 // TODO(verwaest): For now this doesn't call into
167 // ExecutableAccessorInfo, since clients don't need it. Update once 169 // ExecutableAccessorInfo, since clients don't need it. Update once
168 // relevant. 170 // relevant.
169 it->NotFound(); 171 it->NotFound();
170 return it->isolate()->factory()->undefined_value(); 172 return it->isolate()->factory()->undefined_value();
173 case LookupIterator::INTEGER_INDEXED_EXOTIC:
174 return it->isolate()->factory()->undefined_value();
171 case LookupIterator::DATA: 175 case LookupIterator::DATA:
172 return it->GetDataValue(); 176 return it->GetDataValue();
173 } 177 }
174 } 178 }
175 return it->isolate()->factory()->undefined_value(); 179 return it->isolate()->factory()->undefined_value();
176 } 180 }
177 181
178 182
179 bool Object::ToInt32(int32_t* value) { 183 bool Object::ToInt32(int32_t* value) {
180 if (IsSmi()) { 184 if (IsSmi()) {
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 break; 3127 break;
3124 3128
3125 case LookupIterator::ACCESSOR: 3129 case LookupIterator::ACCESSOR:
3126 if (it->property_details().IsReadOnly()) { 3130 if (it->property_details().IsReadOnly()) {
3127 return WriteToReadOnlyProperty(it, value, language_mode); 3131 return WriteToReadOnlyProperty(it, value, language_mode);
3128 } 3132 }
3129 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value, 3133 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value,
3130 it->GetHolder<JSObject>(), 3134 it->GetHolder<JSObject>(),
3131 it->GetAccessors(), language_mode); 3135 it->GetAccessors(), language_mode);
3132 3136
3137 case LookupIterator::INTEGER_INDEXED_EXOTIC:
3138 done = true;
3139 break;
3140
3133 case LookupIterator::DATA: 3141 case LookupIterator::DATA:
3134 if (it->property_details().IsReadOnly()) { 3142 if (it->property_details().IsReadOnly()) {
3135 return WriteToReadOnlyProperty(it, value, language_mode); 3143 return WriteToReadOnlyProperty(it, value, language_mode);
3136 } 3144 }
3137 if (it->HolderIsReceiverOrHiddenPrototype()) { 3145 if (it->HolderIsReceiverOrHiddenPrototype()) {
3138 return SetDataProperty(it, value); 3146 return SetDataProperty(it, value);
3139 } 3147 }
3140 done = true; 3148 done = true;
3141 break; 3149 break;
3142 3150
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 SetPropertyInternal(it, value, language_mode, store_mode, &found); 3193 SetPropertyInternal(it, value, language_mode, store_mode, &found);
3186 if (found) return result; 3194 if (found) return result;
3187 3195
3188 LookupIterator own_lookup(it->GetReceiver(), it->name(), LookupIterator::OWN); 3196 LookupIterator own_lookup(it->GetReceiver(), it->name(), LookupIterator::OWN);
3189 3197
3190 switch (own_lookup.state()) { 3198 switch (own_lookup.state()) {
3191 case LookupIterator::NOT_FOUND: 3199 case LookupIterator::NOT_FOUND:
3192 return JSObject::AddDataProperty(&own_lookup, value, NONE, language_mode, 3200 return JSObject::AddDataProperty(&own_lookup, value, NONE, language_mode,
3193 store_mode); 3201 store_mode);
3194 3202
3203 case LookupIterator::INTEGER_INDEXED_EXOTIC:
3204 return result;
3205
3195 case LookupIterator::DATA: { 3206 case LookupIterator::DATA: {
3196 PropertyDetails details = own_lookup.property_details(); 3207 PropertyDetails details = own_lookup.property_details();
3197 if (details.IsConfigurable() || !details.IsReadOnly()) { 3208 if (details.IsConfigurable() || !details.IsReadOnly()) {
3198 return JSObject::SetOwnPropertyIgnoreAttributes( 3209 return JSObject::SetOwnPropertyIgnoreAttributes(
3199 Handle<JSObject>::cast(it->GetReceiver()), it->name(), value, 3210 Handle<JSObject>::cast(it->GetReceiver()), it->name(), value,
3200 details.attributes()); 3211 details.attributes());
3201 } 3212 }
3202 return WriteToReadOnlyProperty(&own_lookup, value, language_mode); 3213 return WriteToReadOnlyProperty(&own_lookup, value, language_mode);
3203 } 3214 }
3204 3215
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 Handle<Object> value, 3325 Handle<Object> value,
3315 PropertyAttributes attributes, 3326 PropertyAttributes attributes,
3316 LanguageMode language_mode, 3327 LanguageMode language_mode,
3317 StoreFromKeyed store_mode) { 3328 StoreFromKeyed store_mode) {
3318 DCHECK(!it->GetReceiver()->IsJSProxy()); 3329 DCHECK(!it->GetReceiver()->IsJSProxy());
3319 if (!it->GetReceiver()->IsJSObject()) { 3330 if (!it->GetReceiver()->IsJSObject()) {
3320 // TODO(verwaest): Throw a TypeError with a more specific message. 3331 // TODO(verwaest): Throw a TypeError with a more specific message.
3321 return WriteToReadOnlyProperty(it, value, language_mode); 3332 return WriteToReadOnlyProperty(it, value, language_mode);
3322 } 3333 }
3323 3334
3335 if (it->state() == LookupIterator::INTEGER_INDEXED_EXOTIC) return value;
3336
3324 Handle<JSObject> receiver = it->GetStoreTarget(); 3337 Handle<JSObject> receiver = it->GetStoreTarget();
3325 3338
3326 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject) 3339 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject)
3327 // instead. If the prototype is Null, the proxy is detached. 3340 // instead. If the prototype is Null, the proxy is detached.
3328 if (receiver->IsJSGlobalProxy()) return value; 3341 if (receiver->IsJSGlobalProxy()) return value;
3329 3342
3330 // If the receiver is Indexed Exotic object (currently only typed arrays),
3331 // disallow adding properties with numeric names.
3332 if (it->IsSpecialNumericIndex()) return value;
3333
3334 // Possibly migrate to the most up-to-date map that will be able to store 3343 // Possibly migrate to the most up-to-date map that will be able to store
3335 // |value| under it->name() with |attributes|. 3344 // |value| under it->name() with |attributes|.
3336 it->PrepareTransitionToDataProperty(value, attributes, store_mode); 3345 it->PrepareTransitionToDataProperty(value, attributes, store_mode);
3337 if (it->state() != LookupIterator::TRANSITION) { 3346 if (it->state() != LookupIterator::TRANSITION) {
3338 if (is_sloppy(language_mode)) return value; 3347 if (is_sloppy(language_mode)) return value;
3339 3348
3340 Handle<Object> args[] = {it->name()}; 3349 Handle<Object> args[] = {it->name()};
3341 THROW_NEW_ERROR(it->isolate(), 3350 THROW_NEW_ERROR(it->isolate(),
3342 NewTypeError("object_not_extensible", 3351 NewTypeError("object_not_extensible",
3343 HandleVector(args, arraysize(args))), 3352 HandleVector(args, arraysize(args))),
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
4151 Handle<Name> name, 4160 Handle<Name> name,
4152 Handle<Object> value, 4161 Handle<Object> value,
4153 PropertyAttributes attributes, 4162 PropertyAttributes attributes,
4154 ExecutableAccessorInfoHandling handling) { 4163 ExecutableAccessorInfoHandling handling) {
4155 DCHECK(!value->IsTheHole()); 4164 DCHECK(!value->IsTheHole());
4156 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 4165 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
4157 bool is_observed = object->map()->is_observed() && 4166 bool is_observed = object->map()->is_observed() &&
4158 !it.isolate()->IsInternallyUsedPropertyName(name); 4167 !it.isolate()->IsInternallyUsedPropertyName(name);
4159 for (; it.IsFound(); it.Next()) { 4168 for (; it.IsFound(); it.Next()) {
4160 switch (it.state()) { 4169 switch (it.state()) {
4170 case LookupIterator::INTEGER_INDEXED_EXOTIC:
4161 case LookupIterator::INTERCEPTOR: 4171 case LookupIterator::INTERCEPTOR:
4162 case LookupIterator::JSPROXY: 4172 case LookupIterator::JSPROXY:
4163 case LookupIterator::NOT_FOUND: 4173 case LookupIterator::NOT_FOUND:
4164 case LookupIterator::TRANSITION: 4174 case LookupIterator::TRANSITION:
4165 UNREACHABLE(); 4175 UNREACHABLE();
4166 4176
4167 case LookupIterator::ACCESS_CHECK: 4177 case LookupIterator::ACCESS_CHECK:
4168 if (!it.isolate()->MayAccess(object)) { 4178 if (!it.isolate()->MayAccess(object)) {
4169 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); 4179 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY);
4170 } 4180 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 Maybe<PropertyAttributes> result = 4339 Maybe<PropertyAttributes> result =
4330 JSObject::GetPropertyAttributesWithInterceptor( 4340 JSObject::GetPropertyAttributesWithInterceptor(
4331 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 4341 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
4332 if (!result.IsJust()) return result; 4342 if (!result.IsJust()) return result;
4333 if (result.FromJust() != ABSENT) return result; 4343 if (result.FromJust() != ABSENT) return result;
4334 break; 4344 break;
4335 } 4345 }
4336 case LookupIterator::ACCESS_CHECK: 4346 case LookupIterator::ACCESS_CHECK:
4337 if (it->HasAccess()) break; 4347 if (it->HasAccess()) break;
4338 return JSObject::GetPropertyAttributesWithFailedAccessCheck(it); 4348 return JSObject::GetPropertyAttributesWithFailedAccessCheck(it);
4349 case LookupIterator::INTEGER_INDEXED_EXOTIC:
4350 return Just(ABSENT);
4339 case LookupIterator::ACCESSOR: 4351 case LookupIterator::ACCESSOR:
4340 case LookupIterator::DATA: 4352 case LookupIterator::DATA:
4341 return Just(it->property_details().attributes()); 4353 return Just(it->property_details().attributes());
4342 } 4354 }
4343 } 4355 }
4344 return Just(ABSENT); 4356 return Just(ABSENT);
4345 } 4357 }
4346 4358
4347 4359
4348 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithReceiver( 4360 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithReceiver(
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
5330 case LookupIterator::INTERCEPTOR: { 5342 case LookupIterator::INTERCEPTOR: {
5331 MaybeHandle<Object> maybe_result = 5343 MaybeHandle<Object> maybe_result =
5332 JSObject::DeletePropertyWithInterceptor(it.GetHolder<JSObject>(), 5344 JSObject::DeletePropertyWithInterceptor(it.GetHolder<JSObject>(),
5333 object, it.name()); 5345 object, it.name());
5334 // Delete with interceptor succeeded. Return result. 5346 // Delete with interceptor succeeded. Return result.
5335 if (!maybe_result.is_null()) return maybe_result; 5347 if (!maybe_result.is_null()) return maybe_result;
5336 // An exception was thrown in the interceptor. Propagate. 5348 // An exception was thrown in the interceptor. Propagate.
5337 if (it.isolate()->has_pending_exception()) return maybe_result; 5349 if (it.isolate()->has_pending_exception()) return maybe_result;
5338 break; 5350 break;
5339 } 5351 }
5352 case LookupIterator::INTEGER_INDEXED_EXOTIC:
5353 return it.isolate()->factory()->true_value();
5340 case LookupIterator::DATA: 5354 case LookupIterator::DATA:
5341 if (is_observed) { 5355 if (is_observed) {
5342 old_value = it.GetDataValue(); 5356 old_value = it.GetDataValue();
5343 } 5357 }
5344 // Fall through. 5358 // Fall through.
5345 case LookupIterator::ACCESSOR: { 5359 case LookupIterator::ACCESSOR: {
5346 if (!it.IsConfigurable()) { 5360 if (!it.IsConfigurable()) {
5347 // Fail if the property is not configurable. 5361 // Fail if the property is not configurable.
5348 if (is_strict(language_mode)) { 5362 if (is_strict(language_mode)) {
5349 Handle<Object> args[] = {name, object}; 5363 Handle<Object> args[] = {name, object};
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6757 6771
6758 case LookupIterator::ACCESS_CHECK: 6772 case LookupIterator::ACCESS_CHECK:
6759 if (it.HasAccess()) continue; 6773 if (it.HasAccess()) continue;
6760 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); 6774 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
6761 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 6775 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6762 return isolate->factory()->undefined_value(); 6776 return isolate->factory()->undefined_value();
6763 6777
6764 case LookupIterator::JSPROXY: 6778 case LookupIterator::JSPROXY:
6765 return isolate->factory()->undefined_value(); 6779 return isolate->factory()->undefined_value();
6766 6780
6781 case LookupIterator::INTEGER_INDEXED_EXOTIC:
6782 return isolate->factory()->undefined_value();
6767 case LookupIterator::DATA: 6783 case LookupIterator::DATA:
6768 continue; 6784 continue;
6769 case LookupIterator::ACCESSOR: { 6785 case LookupIterator::ACCESSOR: {
6770 Handle<Object> maybe_pair = it.GetAccessors(); 6786 Handle<Object> maybe_pair = it.GetAccessors();
6771 if (maybe_pair->IsAccessorPair()) { 6787 if (maybe_pair->IsAccessorPair()) {
6772 return handle( 6788 return handle(
6773 AccessorPair::cast(*maybe_pair)->GetComponent(component), 6789 AccessorPair::cast(*maybe_pair)->GetComponent(component),
6774 isolate); 6790 isolate);
6775 } 6791 }
6776 } 6792 }
(...skipping 10293 matching lines...) Expand 10 before | Expand all | Expand 10 after
17070 CompilationInfo* info) { 17086 CompilationInfo* info) {
17071 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17087 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17072 handle(cell->dependent_code(), info->isolate()), 17088 handle(cell->dependent_code(), info->isolate()),
17073 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17089 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17074 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17090 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17075 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17091 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17076 cell, info->zone()); 17092 cell, info->zone());
17077 } 17093 }
17078 17094
17079 } } // namespace v8::internal 17095 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup-inl.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698