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

Side by Side Diff: src/objects.cc

Issue 291153005: Consistently say 'own' property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add new files Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('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 "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "allocation-site-scopes.h" 8 #include "allocation-site-scopes.h"
9 #include "api.h" 9 #include "api.h"
10 #include "arguments.h" 10 #include "arguments.h"
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 break; 553 break;
554 } 554 }
555 555
556 case INTERCEPTOR: { 556 case INTERCEPTOR: {
557 // If the object has an interceptor, try real named properties. 557 // If the object has an interceptor, try real named properties.
558 // No access check in GetPropertyAttributeWithInterceptor. 558 // No access check in GetPropertyAttributeWithInterceptor.
559 LookupResult r(object->GetIsolate()); 559 LookupResult r(object->GetIsolate());
560 if (continue_search) { 560 if (continue_search) {
561 result->holder()->LookupRealNamedProperty(name, &r); 561 result->holder()->LookupRealNamedProperty(name, &r);
562 } else { 562 } else {
563 result->holder()->LocalLookupRealNamedProperty(name, &r); 563 result->holder()->LookupOwnRealNamedProperty(name, &r);
564 } 564 }
565 if (!r.IsFound()) break; 565 if (!r.IsFound()) break;
566 return GetPropertyAttributeWithFailedAccessCheck( 566 return GetPropertyAttributeWithFailedAccessCheck(
567 object, &r, name, continue_search); 567 object, &r, name, continue_search);
568 } 568 }
569 569
570 case HANDLER: 570 case HANDLER:
571 case NONEXISTENT: 571 case NONEXISTENT:
572 UNREACHABLE(); 572 UNREACHABLE();
573 } 573 }
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 argc, args).Assert(); 1988 argc, args).Assert();
1989 } 1989 }
1990 1990
1991 1991
1992 MaybeHandle<Object> JSObject::SetPropertyPostInterceptor( 1992 MaybeHandle<Object> JSObject::SetPropertyPostInterceptor(
1993 Handle<JSObject> object, 1993 Handle<JSObject> object,
1994 Handle<Name> name, 1994 Handle<Name> name,
1995 Handle<Object> value, 1995 Handle<Object> value,
1996 PropertyAttributes attributes, 1996 PropertyAttributes attributes,
1997 StrictMode strict_mode) { 1997 StrictMode strict_mode) {
1998 // Check local property, ignore interceptor. 1998 // Check own property, ignore interceptor.
1999 Isolate* isolate = object->GetIsolate(); 1999 Isolate* isolate = object->GetIsolate();
2000 LookupResult result(isolate); 2000 LookupResult result(isolate);
2001 object->LocalLookupRealNamedProperty(name, &result); 2001 object->LookupOwnRealNamedProperty(name, &result);
2002 if (!result.IsFound()) { 2002 if (!result.IsFound()) {
2003 object->map()->LookupTransition(*object, *name, &result); 2003 object->map()->LookupTransition(*object, *name, &result);
2004 } 2004 }
2005 if (result.IsFound()) { 2005 if (result.IsFound()) {
2006 // An existing property or a map transition was found. Use set property to 2006 // An existing property or a map transition was found. Use set property to
2007 // handle all these cases. 2007 // handle all these cases.
2008 return SetPropertyForResult(object, &result, name, value, attributes, 2008 return SetPropertyForResult(object, &result, name, value, attributes,
2009 strict_mode, MAY_BE_STORE_FROM_KEYED); 2009 strict_mode, MAY_BE_STORE_FROM_KEYED);
2010 } 2010 }
2011 bool done = false; 2011 bool done = false;
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 } 2970 }
2971 2971
2972 2972
2973 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, 2973 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
2974 Handle<Name> name, 2974 Handle<Name> name,
2975 Handle<Object> value, 2975 Handle<Object> value,
2976 PropertyAttributes attributes, 2976 PropertyAttributes attributes,
2977 StrictMode strict_mode, 2977 StrictMode strict_mode,
2978 StoreFromKeyed store_mode) { 2978 StoreFromKeyed store_mode) {
2979 LookupResult result(object->GetIsolate()); 2979 LookupResult result(object->GetIsolate());
2980 object->LocalLookup(name, &result, true); 2980 object->LookupOwn(name, &result, true);
2981 if (!result.IsFound()) { 2981 if (!result.IsFound()) {
2982 object->map()->LookupTransition(JSObject::cast(*object), *name, &result); 2982 object->map()->LookupTransition(JSObject::cast(*object), *name, &result);
2983 } 2983 }
2984 return SetProperty(object, &result, name, value, attributes, strict_mode, 2984 return SetProperty(object, &result, name, value, attributes, strict_mode,
2985 store_mode); 2985 store_mode);
2986 } 2986 }
2987 2987
2988 2988
2989 MaybeHandle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object, 2989 MaybeHandle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object,
2990 Handle<Object> structure, 2990 Handle<Object> structure,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 MaybeHandle<Object> JSObject::SetPropertyViaPrototypes( 3118 MaybeHandle<Object> JSObject::SetPropertyViaPrototypes(
3119 Handle<JSObject> object, 3119 Handle<JSObject> object,
3120 Handle<Name> name, 3120 Handle<Name> name,
3121 Handle<Object> value, 3121 Handle<Object> value,
3122 PropertyAttributes attributes, 3122 PropertyAttributes attributes,
3123 StrictMode strict_mode, 3123 StrictMode strict_mode,
3124 bool* done) { 3124 bool* done) {
3125 Isolate* isolate = object->GetIsolate(); 3125 Isolate* isolate = object->GetIsolate();
3126 3126
3127 *done = false; 3127 *done = false;
3128 // We could not find a local property so let's check whether there is an 3128 // We could not find an own property, so let's check whether there is an
3129 // accessor that wants to handle the property, or whether the property is 3129 // accessor that wants to handle the property, or whether the property is
3130 // read-only on the prototype chain. 3130 // read-only on the prototype chain.
3131 LookupResult result(isolate); 3131 LookupResult result(isolate);
3132 object->LookupRealNamedPropertyInPrototypes(name, &result); 3132 object->LookupRealNamedPropertyInPrototypes(name, &result);
3133 if (result.IsFound()) { 3133 if (result.IsFound()) {
3134 switch (result.type()) { 3134 switch (result.type()) {
3135 case NORMAL: 3135 case NORMAL:
3136 case FIELD: 3136 case FIELD:
3137 case CONSTANT: 3137 case CONSTANT:
3138 *done = result.IsReadOnly(); 3138 *done = result.IsReadOnly();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3494 } 3494 }
3495 3495
3496 3496
3497 Handle<Map> JSObject::GetElementsTransitionMap(Handle<JSObject> object, 3497 Handle<Map> JSObject::GetElementsTransitionMap(Handle<JSObject> object,
3498 ElementsKind to_kind) { 3498 ElementsKind to_kind) {
3499 Handle<Map> map(object->map()); 3499 Handle<Map> map(object->map());
3500 return Map::TransitionElementsTo(map, to_kind); 3500 return Map::TransitionElementsTo(map, to_kind);
3501 } 3501 }
3502 3502
3503 3503
3504 void JSObject::LocalLookupRealNamedProperty(Handle<Name> name, 3504 void JSObject::LookupOwnRealNamedProperty(Handle<Name> name,
3505 LookupResult* result) { 3505 LookupResult* result) {
3506 DisallowHeapAllocation no_gc; 3506 DisallowHeapAllocation no_gc;
3507 if (IsJSGlobalProxy()) { 3507 if (IsJSGlobalProxy()) {
3508 Object* proto = GetPrototype(); 3508 Object* proto = GetPrototype();
3509 if (proto->IsNull()) return result->NotFound(); 3509 if (proto->IsNull()) return result->NotFound();
3510 ASSERT(proto->IsJSGlobalObject()); 3510 ASSERT(proto->IsJSGlobalObject());
3511 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); 3511 return JSObject::cast(proto)->LookupOwnRealNamedProperty(name, result);
3512 } 3512 }
3513 3513
3514 if (HasFastProperties()) { 3514 if (HasFastProperties()) {
3515 map()->LookupDescriptor(this, *name, result); 3515 map()->LookupDescriptor(this, *name, result);
3516 // A property or a map transition was found. We return all of these result 3516 // A property or a map transition was found. We return all of these result
3517 // types because LocalLookupRealNamedProperty is used when setting 3517 // types because LookupOwnRealNamedProperty is used when setting
3518 // properties where map transitions are handled. 3518 // properties where map transitions are handled.
3519 ASSERT(!result->IsFound() || 3519 ASSERT(!result->IsFound() ||
3520 (result->holder() == this && result->IsFastPropertyType())); 3520 (result->holder() == this && result->IsFastPropertyType()));
3521 // Disallow caching for uninitialized constants. These can only 3521 // Disallow caching for uninitialized constants. These can only
3522 // occur as fields. 3522 // occur as fields.
3523 if (result->IsField() && 3523 if (result->IsField() &&
3524 result->IsReadOnly() && 3524 result->IsReadOnly() &&
3525 RawFastPropertyAt(result->GetFieldIndex().field_index())->IsTheHole()) { 3525 RawFastPropertyAt(result->GetFieldIndex().field_index())->IsTheHole()) {
3526 result->DisallowCaching(); 3526 result->DisallowCaching();
3527 } 3527 }
(...skipping 18 matching lines...) Expand all
3546 return; 3546 return;
3547 } 3547 }
3548 3548
3549 result->NotFound(); 3549 result->NotFound();
3550 } 3550 }
3551 3551
3552 3552
3553 void JSObject::LookupRealNamedProperty(Handle<Name> name, 3553 void JSObject::LookupRealNamedProperty(Handle<Name> name,
3554 LookupResult* result) { 3554 LookupResult* result) {
3555 DisallowHeapAllocation no_gc; 3555 DisallowHeapAllocation no_gc;
3556 LocalLookupRealNamedProperty(name, result); 3556 LookupOwnRealNamedProperty(name, result);
3557 if (result->IsFound()) return; 3557 if (result->IsFound()) return;
3558 3558
3559 LookupRealNamedPropertyInPrototypes(name, result); 3559 LookupRealNamedPropertyInPrototypes(name, result);
3560 } 3560 }
3561 3561
3562 3562
3563 void JSObject::LookupRealNamedPropertyInPrototypes(Handle<Name> name, 3563 void JSObject::LookupRealNamedPropertyInPrototypes(Handle<Name> name,
3564 LookupResult* result) { 3564 LookupResult* result) {
3565 DisallowHeapAllocation no_gc; 3565 DisallowHeapAllocation no_gc;
3566 Isolate* isolate = GetIsolate(); 3566 Isolate* isolate = GetIsolate();
3567 Heap* heap = isolate->heap(); 3567 Heap* heap = isolate->heap();
3568 for (Object* pt = GetPrototype(); 3568 for (Object* pt = GetPrototype();
3569 pt != heap->null_value(); 3569 pt != heap->null_value();
3570 pt = pt->GetPrototype(isolate)) { 3570 pt = pt->GetPrototype(isolate)) {
3571 if (pt->IsJSProxy()) { 3571 if (pt->IsJSProxy()) {
3572 return result->HandlerResult(JSProxy::cast(pt)); 3572 return result->HandlerResult(JSProxy::cast(pt));
3573 } 3573 }
3574 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); 3574 JSObject::cast(pt)->LookupOwnRealNamedProperty(name, result);
3575 ASSERT(!(result->IsFound() && result->type() == INTERCEPTOR)); 3575 ASSERT(!(result->IsFound() && result->type() == INTERCEPTOR));
3576 if (result->IsFound()) return; 3576 if (result->IsFound()) return;
3577 } 3577 }
3578 result->NotFound(); 3578 result->NotFound();
3579 } 3579 }
3580 3580
3581 3581
3582 // We only need to deal with CALLBACKS and INTERCEPTORS 3582 // We only need to deal with CALLBACKS and INTERCEPTORS
3583 MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck( 3583 MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck(
3584 Handle<JSObject> object, 3584 Handle<JSObject> object,
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 lookup->isolate(), field_representation); 4127 lookup->isolate(), field_representation);
4128 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()), 4128 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()),
4129 lookup->GetDescriptorIndex(), 4129 lookup->GetDescriptorIndex(),
4130 field_representation, field_type, 4130 field_representation, field_type,
4131 FORCE_FIELD); 4131 FORCE_FIELD);
4132 } 4132 }
4133 lookup->holder()->WriteToField(lookup->GetDescriptorIndex(), *value); 4133 lookup->holder()->WriteToField(lookup->GetDescriptorIndex(), *value);
4134 } 4134 }
4135 4135
4136 4136
4137 static void ConvertAndSetLocalProperty(LookupResult* lookup, 4137 static void ConvertAndSetOwnProperty(LookupResult* lookup,
4138 Handle<Name> name, 4138 Handle<Name> name,
4139 Handle<Object> value, 4139 Handle<Object> value,
4140 PropertyAttributes attributes) { 4140 PropertyAttributes attributes) {
4141 Handle<JSObject> object(lookup->holder()); 4141 Handle<JSObject> object(lookup->holder());
4142 if (object->TooManyFastProperties()) { 4142 if (object->TooManyFastProperties()) {
4143 JSObject::NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); 4143 JSObject::NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
4144 } 4144 }
4145 4145
4146 if (!object->HasFastProperties()) { 4146 if (!object->HasFastProperties()) {
4147 ReplaceSlowProperty(object, name, value, attributes); 4147 ReplaceSlowProperty(object, name, value, attributes);
4148 return; 4148 return;
4149 } 4149 }
4150 4150
(...skipping 14 matching lines...) Expand all
4165 4165
4166 4166
4167 static void SetPropertyToFieldWithAttributes(LookupResult* lookup, 4167 static void SetPropertyToFieldWithAttributes(LookupResult* lookup,
4168 Handle<Name> name, 4168 Handle<Name> name,
4169 Handle<Object> value, 4169 Handle<Object> value,
4170 PropertyAttributes attributes) { 4170 PropertyAttributes attributes) {
4171 if (lookup->GetAttributes() == attributes) { 4171 if (lookup->GetAttributes() == attributes) {
4172 if (value->IsUninitialized()) return; 4172 if (value->IsUninitialized()) return;
4173 SetPropertyToField(lookup, value); 4173 SetPropertyToField(lookup, value);
4174 } else { 4174 } else {
4175 ConvertAndSetLocalProperty(lookup, name, value, attributes); 4175 ConvertAndSetOwnProperty(lookup, name, value, attributes);
4176 } 4176 }
4177 } 4177 }
4178 4178
4179 4179
4180 MaybeHandle<Object> JSObject::SetPropertyForResult( 4180 MaybeHandle<Object> JSObject::SetPropertyForResult(
4181 Handle<JSObject> object, 4181 Handle<JSObject> object,
4182 LookupResult* lookup, 4182 LookupResult* lookup,
4183 Handle<Name> name, 4183 Handle<Name> name,
4184 Handle<Object> value, 4184 Handle<Object> value,
4185 PropertyAttributes attributes, 4185 PropertyAttributes attributes,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4288 } 4288 }
4289 4289
4290 Handle<Object> result; 4290 Handle<Object> result;
4291 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); 4291 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
4292 4292
4293 if (is_observed) { 4293 if (is_observed) {
4294 if (lookup->IsTransition()) { 4294 if (lookup->IsTransition()) {
4295 EnqueueChangeRecord(object, "add", name, old_value); 4295 EnqueueChangeRecord(object, "add", name, old_value);
4296 } else { 4296 } else {
4297 LookupResult new_lookup(isolate); 4297 LookupResult new_lookup(isolate);
4298 object->LocalLookup(name, &new_lookup, true); 4298 object->LookupOwn(name, &new_lookup, true);
4299 if (new_lookup.IsDataProperty()) { 4299 if (new_lookup.IsDataProperty()) {
4300 Handle<Object> new_value = 4300 Handle<Object> new_value =
4301 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 4301 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4302 if (!new_value->SameValue(*old_value)) { 4302 if (!new_value->SameValue(*old_value)) {
4303 EnqueueChangeRecord(object, "update", name, old_value); 4303 EnqueueChangeRecord(object, "update", name, old_value);
4304 } 4304 }
4305 } 4305 }
4306 } 4306 }
4307 } 4307 }
4308 4308
4309 return result; 4309 return result;
4310 } 4310 }
4311 4311
4312 4312
4313 // Set a real local property, even if it is READ_ONLY. If the property is not 4313 // Set a real own property, even if it is READ_ONLY. If the property is not
4314 // present, add it with attributes NONE. This code is an exact clone of 4314 // present, add it with attributes NONE. This code is an exact clone of
4315 // SetProperty, with the check for IsReadOnly and the check for a 4315 // SetProperty, with the check for IsReadOnly and the check for a
4316 // callback setter removed. The two lines looking up the LookupResult 4316 // callback setter removed. The two lines looking up the LookupResult
4317 // result are also added. If one of the functions is changed, the other 4317 // result are also added. If one of the functions is changed, the other
4318 // should be. 4318 // should be.
4319 // Note that this method cannot be used to set the prototype of a function 4319 // Note that this method cannot be used to set the prototype of a function
4320 // because ConvertDescriptorToField() which is called in "case CALLBACKS:" 4320 // because ConvertDescriptorToField() which is called in "case CALLBACKS:"
4321 // doesn't handle function prototypes correctly. 4321 // doesn't handle function prototypes correctly.
4322 MaybeHandle<Object> JSObject::SetLocalPropertyIgnoreAttributes( 4322 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
4323 Handle<JSObject> object, 4323 Handle<JSObject> object,
4324 Handle<Name> name, 4324 Handle<Name> name,
4325 Handle<Object> value, 4325 Handle<Object> value,
4326 PropertyAttributes attributes, 4326 PropertyAttributes attributes,
4327 ValueType value_type, 4327 ValueType value_type,
4328 StoreMode mode, 4328 StoreMode mode,
4329 ExtensibilityCheck extensibility_check, 4329 ExtensibilityCheck extensibility_check,
4330 StoreFromKeyed store_from_keyed) { 4330 StoreFromKeyed store_from_keyed) {
4331 Isolate* isolate = object->GetIsolate(); 4331 Isolate* isolate = object->GetIsolate();
4332 4332
4333 // Make sure that the top context does not change when doing callbacks or 4333 // Make sure that the top context does not change when doing callbacks or
4334 // interceptor calls. 4334 // interceptor calls.
4335 AssertNoContextChange ncc(isolate); 4335 AssertNoContextChange ncc(isolate);
4336 4336
4337 LookupResult lookup(isolate); 4337 LookupResult lookup(isolate);
4338 object->LocalLookup(name, &lookup, true); 4338 object->LookupOwn(name, &lookup, true);
4339 if (!lookup.IsFound()) { 4339 if (!lookup.IsFound()) {
4340 object->map()->LookupTransition(*object, *name, &lookup); 4340 object->map()->LookupTransition(*object, *name, &lookup);
4341 } 4341 }
4342 4342
4343 // Check access rights if needed. 4343 // Check access rights if needed.
4344 if (object->IsAccessCheckNeeded()) { 4344 if (object->IsAccessCheckNeeded()) {
4345 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { 4345 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) {
4346 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, 4346 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value,
4347 false, SLOPPY); 4347 false, SLOPPY);
4348 } 4348 }
4349 } 4349 }
4350 4350
4351 if (object->IsJSGlobalProxy()) { 4351 if (object->IsJSGlobalProxy()) {
4352 Handle<Object> proto(object->GetPrototype(), isolate); 4352 Handle<Object> proto(object->GetPrototype(), isolate);
4353 if (proto->IsNull()) return value; 4353 if (proto->IsNull()) return value;
4354 ASSERT(proto->IsJSGlobalObject()); 4354 ASSERT(proto->IsJSGlobalObject());
4355 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), 4355 return SetOwnPropertyIgnoreAttributes(Handle<JSObject>::cast(proto),
4356 name, value, attributes, value_type, mode, extensibility_check); 4356 name, value, attributes, value_type, mode, extensibility_check);
4357 } 4357 }
4358 4358
4359 if (lookup.IsInterceptor() || 4359 if (lookup.IsInterceptor() ||
4360 (lookup.IsDescriptorOrDictionary() && lookup.type() == CALLBACKS)) { 4360 (lookup.IsDescriptorOrDictionary() && lookup.type() == CALLBACKS)) {
4361 object->LocalLookupRealNamedProperty(name, &lookup); 4361 object->LookupOwnRealNamedProperty(name, &lookup);
4362 } 4362 }
4363 4363
4364 // Check for accessor in prototype chain removed here in clone. 4364 // Check for accessor in prototype chain removed here in clone.
4365 if (!lookup.IsFound()) { 4365 if (!lookup.IsFound()) {
4366 object->map()->LookupTransition(*object, *name, &lookup); 4366 object->map()->LookupTransition(*object, *name, &lookup);
4367 TransitionFlag flag = lookup.IsFound() 4367 TransitionFlag flag = lookup.IsFound()
4368 ? OMIT_TRANSITION : INSERT_TRANSITION; 4368 ? OMIT_TRANSITION : INSERT_TRANSITION;
4369 // Neither properties nor transitions found. 4369 // Neither properties nor transitions found.
4370 return AddProperty(object, name, value, attributes, SLOPPY, 4370 return AddProperty(object, name, value, attributes, SLOPPY,
4371 store_from_keyed, extensibility_check, value_type, mode, flag); 4371 store_from_keyed, extensibility_check, value_type, mode, flag);
(...skipping 27 matching lines...) Expand all
4399 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); 4399 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes);
4400 break; 4400 break;
4401 case CONSTANT: 4401 case CONSTANT:
4402 // Only replace the constant if necessary. 4402 // Only replace the constant if necessary.
4403 if (lookup.GetAttributes() != attributes || 4403 if (lookup.GetAttributes() != attributes ||
4404 *value != lookup.GetConstant()) { 4404 *value != lookup.GetConstant()) {
4405 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes); 4405 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes);
4406 } 4406 }
4407 break; 4407 break;
4408 case CALLBACKS: 4408 case CALLBACKS:
4409 ConvertAndSetLocalProperty(&lookup, name, value, attributes); 4409 ConvertAndSetOwnProperty(&lookup, name, value, attributes);
4410 break; 4410 break;
4411 case NONEXISTENT: 4411 case NONEXISTENT:
4412 case HANDLER: 4412 case HANDLER:
4413 case INTERCEPTOR: 4413 case INTERCEPTOR:
4414 UNREACHABLE(); 4414 UNREACHABLE();
4415 } 4415 }
4416 } 4416 }
4417 4417
4418 if (is_observed) { 4418 if (is_observed) {
4419 if (lookup.IsTransition()) { 4419 if (lookup.IsTransition()) {
4420 EnqueueChangeRecord(object, "add", name, old_value); 4420 EnqueueChangeRecord(object, "add", name, old_value);
4421 } else if (old_value->IsTheHole()) { 4421 } else if (old_value->IsTheHole()) {
4422 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4422 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4423 } else { 4423 } else {
4424 LookupResult new_lookup(isolate); 4424 LookupResult new_lookup(isolate);
4425 object->LocalLookup(name, &new_lookup, true); 4425 object->LookupOwn(name, &new_lookup, true);
4426 bool value_changed = false; 4426 bool value_changed = false;
4427 if (new_lookup.IsDataProperty()) { 4427 if (new_lookup.IsDataProperty()) {
4428 Handle<Object> new_value = 4428 Handle<Object> new_value =
4429 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 4429 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4430 value_changed = !old_value->SameValue(*new_value); 4430 value_changed = !old_value->SameValue(*new_value);
4431 } 4431 }
4432 if (new_lookup.GetAttributes() != old_attributes) { 4432 if (new_lookup.GetAttributes() != old_attributes) {
4433 if (!value_changed) old_value = isolate->factory()->the_hole_value(); 4433 if (!value_changed) old_value = isolate->factory()->the_hole_value();
4434 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4434 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4435 } else if (value_changed) { 4435 } else if (value_changed) {
4436 EnqueueChangeRecord(object, "update", name, old_value); 4436 EnqueueChangeRecord(object, "update", name, old_value);
4437 } 4437 }
4438 } 4438 }
4439 } 4439 }
4440 4440
4441 return value; 4441 return value;
4442 } 4442 }
4443 4443
4444 4444
4445 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( 4445 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor(
4446 Handle<JSObject> object, 4446 Handle<JSObject> object,
4447 Handle<JSObject> receiver, 4447 Handle<JSObject> receiver,
4448 Handle<Name> name, 4448 Handle<Name> name,
4449 bool continue_search) { 4449 bool continue_search) {
4450 // Check local property, ignore interceptor. 4450 // Check own property, ignore interceptor.
4451 Isolate* isolate = object->GetIsolate(); 4451 Isolate* isolate = object->GetIsolate();
4452 LookupResult result(isolate); 4452 LookupResult result(isolate);
4453 object->LocalLookupRealNamedProperty(name, &result); 4453 object->LookupOwnRealNamedProperty(name, &result);
4454 if (result.IsFound()) return result.GetAttributes(); 4454 if (result.IsFound()) return result.GetAttributes();
4455 4455
4456 if (continue_search) { 4456 if (continue_search) {
4457 // Continue searching via the prototype chain. 4457 // Continue searching via the prototype chain.
4458 Handle<Object> proto(object->GetPrototype(), isolate); 4458 Handle<Object> proto(object->GetPrototype(), isolate);
4459 if (!proto->IsNull()) { 4459 if (!proto->IsNull()) {
4460 return JSReceiver::GetPropertyAttributeWithReceiver( 4460 return JSReceiver::GetPropertyAttributeWithReceiver(
4461 Handle<JSObject>::cast(proto), receiver, name); 4461 Handle<JSObject>::cast(proto), receiver, name);
4462 } 4462 }
4463 } 4463 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4557 name, 4557 name,
4558 continue_search); 4558 continue_search);
4559 case NONEXISTENT: 4559 case NONEXISTENT:
4560 UNREACHABLE(); 4560 UNREACHABLE();
4561 } 4561 }
4562 } 4562 }
4563 return ABSENT; 4563 return ABSENT;
4564 } 4564 }
4565 4565
4566 4566
4567 PropertyAttributes JSReceiver::GetLocalPropertyAttribute( 4567 PropertyAttributes JSReceiver::GetOwnPropertyAttribute(
4568 Handle<JSReceiver> object, Handle<Name> name) { 4568 Handle<JSReceiver> object, Handle<Name> name) {
4569 // Check whether the name is an array index. 4569 // Check whether the name is an array index.
4570 uint32_t index = 0; 4570 uint32_t index = 0;
4571 if (object->IsJSObject() && name->AsArrayIndex(&index)) { 4571 if (object->IsJSObject() && name->AsArrayIndex(&index)) {
4572 return GetLocalElementAttribute(object, index); 4572 return GetOwnElementAttribute(object, index);
4573 } 4573 }
4574 // Named property. 4574 // Named property.
4575 LookupResult lookup(object->GetIsolate()); 4575 LookupResult lookup(object->GetIsolate());
4576 object->LocalLookup(name, &lookup, true); 4576 object->LookupOwn(name, &lookup, true);
4577 return GetPropertyAttributeForResult(object, object, &lookup, name, false); 4577 return GetPropertyAttributeForResult(object, object, &lookup, name, false);
4578 } 4578 }
4579 4579
4580 4580
4581 PropertyAttributes JSObject::GetElementAttributeWithReceiver( 4581 PropertyAttributes JSObject::GetElementAttributeWithReceiver(
4582 Handle<JSObject> object, 4582 Handle<JSObject> object,
4583 Handle<JSReceiver> receiver, 4583 Handle<JSReceiver> receiver,
4584 uint32_t index, 4584 uint32_t index,
4585 bool continue_search) { 4585 bool continue_search) {
4586 Isolate* isolate = object->GetIsolate(); 4586 Isolate* isolate = object->GetIsolate();
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
5273 descriptors->GetFieldIndex(sorted_index)); 5273 descriptors->GetFieldIndex(sorted_index));
5274 } else { 5274 } else {
5275 return GetHeap()->undefined_value(); 5275 return GetHeap()->undefined_value();
5276 } 5276 }
5277 } else { 5277 } else {
5278 return GetHeap()->undefined_value(); 5278 return GetHeap()->undefined_value();
5279 } 5279 }
5280 } else { 5280 } else {
5281 Isolate* isolate = GetIsolate(); 5281 Isolate* isolate = GetIsolate();
5282 LookupResult result(isolate); 5282 LookupResult result(isolate);
5283 LocalLookupRealNamedProperty(isolate->factory()->hidden_string(), &result); 5283 LookupOwnRealNamedProperty(isolate->factory()->hidden_string(), &result);
5284 if (result.IsFound()) { 5284 if (result.IsFound()) {
5285 ASSERT(result.IsNormal()); 5285 ASSERT(result.IsNormal());
5286 ASSERT(result.holder() == this); 5286 ASSERT(result.holder() == this);
5287 Object* value = GetNormalizedProperty(&result); 5287 Object* value = GetNormalizedProperty(&result);
5288 if (!value->IsTheHole()) return value; 5288 if (!value->IsTheHole()) return value;
5289 } 5289 }
5290 return GetHeap()->undefined_value(); 5290 return GetHeap()->undefined_value();
5291 } 5291 }
5292 } 5292 }
5293 5293
(...skipping 11 matching lines...) Expand all
5305 isolate, kInitialCapacity, USE_CUSTOM_MINIMUM_CAPACITY); 5305 isolate, kInitialCapacity, USE_CUSTOM_MINIMUM_CAPACITY);
5306 5306
5307 if (inline_value->IsSmi()) { 5307 if (inline_value->IsSmi()) {
5308 // We were storing the identity hash inline and now allocated an actual 5308 // We were storing the identity hash inline and now allocated an actual
5309 // dictionary. Put the identity hash into the new dictionary. 5309 // dictionary. Put the identity hash into the new dictionary.
5310 hashtable = ObjectHashTable::Put(hashtable, 5310 hashtable = ObjectHashTable::Put(hashtable,
5311 isolate->factory()->identity_hash_string(), 5311 isolate->factory()->identity_hash_string(),
5312 inline_value); 5312 inline_value);
5313 } 5313 }
5314 5314
5315 JSObject::SetLocalPropertyIgnoreAttributes( 5315 JSObject::SetOwnPropertyIgnoreAttributes(
5316 object, 5316 object,
5317 isolate->factory()->hidden_string(), 5317 isolate->factory()->hidden_string(),
5318 hashtable, 5318 hashtable,
5319 DONT_ENUM, 5319 DONT_ENUM,
5320 OPTIMAL_REPRESENTATION, 5320 OPTIMAL_REPRESENTATION,
5321 ALLOW_AS_CONSTANT, 5321 ALLOW_AS_CONSTANT,
5322 OMIT_EXTENSIBILITY_CHECK).Assert(); 5322 OMIT_EXTENSIBILITY_CHECK).Assert();
5323 5323
5324 return hashtable; 5324 return hashtable;
5325 } 5325 }
(...skipping 17 matching lines...) Expand all
5343 if (descriptors->number_of_descriptors() > 0) { 5343 if (descriptors->number_of_descriptors() > 0) {
5344 int sorted_index = descriptors->GetSortedKeyIndex(0); 5344 int sorted_index = descriptors->GetSortedKeyIndex(0);
5345 if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string() 5345 if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string()
5346 && sorted_index < object->map()->NumberOfOwnDescriptors()) { 5346 && sorted_index < object->map()->NumberOfOwnDescriptors()) {
5347 object->WriteToField(sorted_index, *value); 5347 object->WriteToField(sorted_index, *value);
5348 return object; 5348 return object;
5349 } 5349 }
5350 } 5350 }
5351 } 5351 }
5352 5352
5353 SetLocalPropertyIgnoreAttributes(object, 5353 SetOwnPropertyIgnoreAttributes(object,
5354 isolate->factory()->hidden_string(), 5354 isolate->factory()->hidden_string(),
5355 value, 5355 value,
5356 DONT_ENUM, 5356 DONT_ENUM,
5357 OPTIMAL_REPRESENTATION, 5357 OPTIMAL_REPRESENTATION,
5358 ALLOW_AS_CONSTANT, 5358 ALLOW_AS_CONSTANT,
5359 OMIT_EXTENSIBILITY_CHECK).Assert(); 5359 OMIT_EXTENSIBILITY_CHECK).Assert();
5360 return object; 5360 return object;
5361 } 5361 }
5362 5362
5363 5363
5364 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object, 5364 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object,
5365 Handle<Name> name, 5365 Handle<Name> name,
5366 DeleteMode mode) { 5366 DeleteMode mode) {
5367 // Check local property, ignore interceptor. 5367 // Check own property, ignore interceptor.
5368 Isolate* isolate = object->GetIsolate(); 5368 Isolate* isolate = object->GetIsolate();
5369 LookupResult result(isolate); 5369 LookupResult result(isolate);
5370 object->LocalLookupRealNamedProperty(name, &result); 5370 object->LookupOwnRealNamedProperty(name, &result);
5371 if (!result.IsFound()) return isolate->factory()->true_value(); 5371 if (!result.IsFound()) return isolate->factory()->true_value();
5372 5372
5373 // Normalize object if needed. 5373 // Normalize object if needed.
5374 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); 5374 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
5375 5375
5376 return DeleteNormalizedProperty(object, name, mode); 5376 return DeleteNormalizedProperty(object, name, mode);
5377 } 5377 }
5378 5378
5379 5379
5380 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor( 5380 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5473 if (object->IsJSGlobalProxy()) { 5473 if (object->IsJSGlobalProxy()) {
5474 Handle<Object> proto(object->GetPrototype(), isolate); 5474 Handle<Object> proto(object->GetPrototype(), isolate);
5475 if (proto->IsNull()) return factory->false_value(); 5475 if (proto->IsNull()) return factory->false_value();
5476 ASSERT(proto->IsJSGlobalObject()); 5476 ASSERT(proto->IsJSGlobalObject());
5477 return DeleteElement(Handle<JSObject>::cast(proto), index, mode); 5477 return DeleteElement(Handle<JSObject>::cast(proto), index, mode);
5478 } 5478 }
5479 5479
5480 Handle<Object> old_value; 5480 Handle<Object> old_value;
5481 bool should_enqueue_change_record = false; 5481 bool should_enqueue_change_record = false;
5482 if (object->map()->is_observed()) { 5482 if (object->map()->is_observed()) {
5483 should_enqueue_change_record = HasLocalElement(object, index); 5483 should_enqueue_change_record = HasOwnElement(object, index);
5484 if (should_enqueue_change_record) { 5484 if (should_enqueue_change_record) {
5485 if (!GetLocalElementAccessorPair(object, index).is_null()) { 5485 if (!GetOwnElementAccessorPair(object, index).is_null()) {
5486 old_value = Handle<Object>::cast(factory->the_hole_value()); 5486 old_value = Handle<Object>::cast(factory->the_hole_value());
5487 } else { 5487 } else {
5488 old_value = Object::GetElement( 5488 old_value = Object::GetElement(
5489 isolate, object, index).ToHandleChecked(); 5489 isolate, object, index).ToHandleChecked();
5490 } 5490 }
5491 } 5491 }
5492 } 5492 }
5493 5493
5494 // Skip interceptor if forcing deletion. 5494 // Skip interceptor if forcing deletion.
5495 MaybeHandle<Object> maybe_result; 5495 MaybeHandle<Object> maybe_result;
5496 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { 5496 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) {
5497 maybe_result = DeleteElementWithInterceptor(object, index); 5497 maybe_result = DeleteElementWithInterceptor(object, index);
5498 } else { 5498 } else {
5499 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode); 5499 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode);
5500 } 5500 }
5501 Handle<Object> result; 5501 Handle<Object> result;
5502 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); 5502 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
5503 5503
5504 if (should_enqueue_change_record && !HasLocalElement(object, index)) { 5504 if (should_enqueue_change_record && !HasOwnElement(object, index)) {
5505 Handle<String> name = factory->Uint32ToString(index); 5505 Handle<String> name = factory->Uint32ToString(index);
5506 EnqueueChangeRecord(object, "delete", name, old_value); 5506 EnqueueChangeRecord(object, "delete", name, old_value);
5507 } 5507 }
5508 5508
5509 return result; 5509 return result;
5510 } 5510 }
5511 5511
5512 5512
5513 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, 5513 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
5514 Handle<Name> name, 5514 Handle<Name> name,
(...skipping 17 matching lines...) Expand all
5532 return JSGlobalObject::DeleteProperty( 5532 return JSGlobalObject::DeleteProperty(
5533 handle(JSGlobalObject::cast(proto)), name, mode); 5533 handle(JSGlobalObject::cast(proto)), name, mode);
5534 } 5534 }
5535 5535
5536 uint32_t index = 0; 5536 uint32_t index = 0;
5537 if (name->AsArrayIndex(&index)) { 5537 if (name->AsArrayIndex(&index)) {
5538 return DeleteElement(object, index, mode); 5538 return DeleteElement(object, index, mode);
5539 } 5539 }
5540 5540
5541 LookupResult lookup(isolate); 5541 LookupResult lookup(isolate);
5542 object->LocalLookup(name, &lookup, true); 5542 object->LookupOwn(name, &lookup, true);
5543 if (!lookup.IsFound()) return isolate->factory()->true_value(); 5543 if (!lookup.IsFound()) return isolate->factory()->true_value();
5544 // Ignore attributes if forcing a deletion. 5544 // Ignore attributes if forcing a deletion.
5545 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { 5545 if (lookup.IsDontDelete() && mode != FORCE_DELETION) {
5546 if (mode == STRICT_DELETION) { 5546 if (mode == STRICT_DELETION) {
5547 // Deleting a non-configurable property in strict mode. 5547 // Deleting a non-configurable property in strict mode.
5548 Handle<Object> args[2] = { name, object }; 5548 Handle<Object> args[2] = { name, object };
5549 Handle<Object> error = isolate->factory()->NewTypeError( 5549 Handle<Object> error = isolate->factory()->NewTypeError(
5550 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args))); 5550 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args)));
5551 isolate->Throw(*error); 5551 isolate->Throw(*error);
5552 return Handle<Object>(); 5552 return Handle<Object>();
(...skipping 20 matching lines...) Expand all
5573 DeletePropertyWithInterceptor(object, name), 5573 DeletePropertyWithInterceptor(object, name),
5574 Object); 5574 Object);
5575 } 5575 }
5576 } else { 5576 } else {
5577 // Normalize object if needed. 5577 // Normalize object if needed.
5578 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); 5578 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
5579 // Make sure the properties are normalized before removing the entry. 5579 // Make sure the properties are normalized before removing the entry.
5580 result = DeleteNormalizedProperty(object, name, mode); 5580 result = DeleteNormalizedProperty(object, name, mode);
5581 } 5581 }
5582 5582
5583 if (is_observed && !HasLocalProperty(object, name)) { 5583 if (is_observed && !HasOwnProperty(object, name)) {
5584 EnqueueChangeRecord(object, "delete", name, old_value); 5584 EnqueueChangeRecord(object, "delete", name, old_value);
5585 } 5585 }
5586 5586
5587 return result; 5587 return result;
5588 } 5588 }
5589 5589
5590 5590
5591 MaybeHandle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object, 5591 MaybeHandle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object,
5592 uint32_t index, 5592 uint32_t index,
5593 DeleteMode mode) { 5593 DeleteMode mode) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
6027 ElementsKind kind = copy->GetElementsKind(); 6027 ElementsKind kind = copy->GetElementsKind();
6028 if (copying && IsFastSmiOrObjectElementsKind(kind) && 6028 if (copying && IsFastSmiOrObjectElementsKind(kind) &&
6029 FixedArray::cast(copy->elements())->map() == 6029 FixedArray::cast(copy->elements())->map() ==
6030 isolate->heap()->fixed_cow_array_map()) { 6030 isolate->heap()->fixed_cow_array_map()) {
6031 isolate->counters()->cow_arrays_created_runtime()->Increment(); 6031 isolate->counters()->cow_arrays_created_runtime()->Increment();
6032 } 6032 }
6033 6033
6034 if (!shallow) { 6034 if (!shallow) {
6035 HandleScope scope(isolate); 6035 HandleScope scope(isolate);
6036 6036
6037 // Deep copy local properties. 6037 // Deep copy own properties.
6038 if (copy->HasFastProperties()) { 6038 if (copy->HasFastProperties()) {
6039 Handle<DescriptorArray> descriptors(copy->map()->instance_descriptors()); 6039 Handle<DescriptorArray> descriptors(copy->map()->instance_descriptors());
6040 int limit = copy->map()->NumberOfOwnDescriptors(); 6040 int limit = copy->map()->NumberOfOwnDescriptors();
6041 for (int i = 0; i < limit; i++) { 6041 for (int i = 0; i < limit; i++) {
6042 PropertyDetails details = descriptors->GetDetails(i); 6042 PropertyDetails details = descriptors->GetDetails(i);
6043 if (details.type() != FIELD) continue; 6043 if (details.type() != FIELD) continue;
6044 int index = descriptors->GetFieldIndex(i); 6044 int index = descriptors->GetFieldIndex(i);
6045 Handle<Object> value(object->RawFastPropertyAt(index), isolate); 6045 Handle<Object> value(object->RawFastPropertyAt(index), isolate);
6046 if (value->IsJSObject()) { 6046 if (value->IsJSObject()) {
6047 ASSIGN_RETURN_ON_EXCEPTION( 6047 ASSIGN_RETURN_ON_EXCEPTION(
6048 isolate, value, 6048 isolate, value,
6049 VisitElementOrProperty(copy, Handle<JSObject>::cast(value)), 6049 VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
6050 JSObject); 6050 JSObject);
6051 } else { 6051 } else {
6052 Representation representation = details.representation(); 6052 Representation representation = details.representation();
6053 value = Object::NewStorageFor(isolate, value, representation); 6053 value = Object::NewStorageFor(isolate, value, representation);
6054 } 6054 }
6055 if (copying) { 6055 if (copying) {
6056 copy->FastPropertyAtPut(index, *value); 6056 copy->FastPropertyAtPut(index, *value);
6057 } 6057 }
6058 } 6058 }
6059 } else { 6059 } else {
6060 Handle<FixedArray> names = 6060 Handle<FixedArray> names =
6061 isolate->factory()->NewFixedArray(copy->NumberOfLocalProperties()); 6061 isolate->factory()->NewFixedArray(copy->NumberOfOwnProperties());
6062 copy->GetLocalPropertyNames(*names, 0); 6062 copy->GetOwnPropertyNames(*names, 0);
6063 for (int i = 0; i < names->length(); i++) { 6063 for (int i = 0; i < names->length(); i++) {
6064 ASSERT(names->get(i)->IsString()); 6064 ASSERT(names->get(i)->IsString());
6065 Handle<String> key_string(String::cast(names->get(i))); 6065 Handle<String> key_string(String::cast(names->get(i)));
6066 PropertyAttributes attributes = 6066 PropertyAttributes attributes =
6067 JSReceiver::GetLocalPropertyAttribute(copy, key_string); 6067 JSReceiver::GetOwnPropertyAttribute(copy, key_string);
6068 // Only deep copy fields from the object literal expression. 6068 // Only deep copy fields from the object literal expression.
6069 // In particular, don't try to copy the length attribute of 6069 // In particular, don't try to copy the length attribute of
6070 // an array. 6070 // an array.
6071 if (attributes != NONE) continue; 6071 if (attributes != NONE) continue;
6072 Handle<Object> value = 6072 Handle<Object> value =
6073 Object::GetProperty(copy, key_string).ToHandleChecked(); 6073 Object::GetProperty(copy, key_string).ToHandleChecked();
6074 if (value->IsJSObject()) { 6074 if (value->IsJSObject()) {
6075 Handle<JSObject> result; 6075 Handle<JSObject> result;
6076 ASSIGN_RETURN_ON_EXCEPTION( 6076 ASSIGN_RETURN_ON_EXCEPTION(
6077 isolate, result, 6077 isolate, result,
6078 VisitElementOrProperty(copy, Handle<JSObject>::cast(value)), 6078 VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
6079 JSObject); 6079 JSObject);
6080 if (copying) { 6080 if (copying) {
6081 // Creating object copy for literals. No strict mode needed. 6081 // Creating object copy for literals. No strict mode needed.
6082 JSObject::SetProperty( 6082 JSObject::SetProperty(
6083 copy, key_string, result, NONE, SLOPPY).Assert(); 6083 copy, key_string, result, NONE, SLOPPY).Assert();
6084 } 6084 }
6085 } 6085 }
6086 } 6086 }
6087 } 6087 }
6088 6088
6089 // Deep copy local elements. 6089 // Deep copy own elements.
6090 // Pixel elements cannot be created using an object literal. 6090 // Pixel elements cannot be created using an object literal.
6091 ASSERT(!copy->HasExternalArrayElements()); 6091 ASSERT(!copy->HasExternalArrayElements());
6092 switch (kind) { 6092 switch (kind) {
6093 case FAST_SMI_ELEMENTS: 6093 case FAST_SMI_ELEMENTS:
6094 case FAST_ELEMENTS: 6094 case FAST_ELEMENTS:
6095 case FAST_HOLEY_SMI_ELEMENTS: 6095 case FAST_HOLEY_SMI_ELEMENTS:
6096 case FAST_HOLEY_ELEMENTS: { 6096 case FAST_HOLEY_ELEMENTS: {
6097 Handle<FixedArray> elements(FixedArray::cast(copy->elements())); 6097 Handle<FixedArray> elements(FixedArray::cast(copy->elements()));
6098 if (elements->map() == isolate->heap()->fixed_cow_array_map()) { 6098 if (elements->map() == isolate->heap()->fixed_cow_array_map()) {
6099 #ifdef DEBUG 6099 #ifdef DEBUG
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
6291 for (int i = 0; i < number_of_own_descriptors; i++) { 6291 for (int i = 0; i < number_of_own_descriptors; i++) {
6292 if (descs->GetType(i) == FIELD) { 6292 if (descs->GetType(i) == FIELD) {
6293 int current_index = descs->GetFieldIndex(i); 6293 int current_index = descs->GetFieldIndex(i);
6294 if (current_index > max_index) max_index = current_index; 6294 if (current_index > max_index) max_index = current_index;
6295 } 6295 }
6296 } 6296 }
6297 return max_index + 1; 6297 return max_index + 1;
6298 } 6298 }
6299 6299
6300 6300
6301 void JSReceiver::LocalLookup( 6301 void JSReceiver::LookupOwn(
6302 Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) { 6302 Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) {
6303 DisallowHeapAllocation no_gc; 6303 DisallowHeapAllocation no_gc;
6304 ASSERT(name->IsName()); 6304 ASSERT(name->IsName());
6305 6305
6306 if (IsJSGlobalProxy()) { 6306 if (IsJSGlobalProxy()) {
6307 Object* proto = GetPrototype(); 6307 Object* proto = GetPrototype();
6308 if (proto->IsNull()) return result->NotFound(); 6308 if (proto->IsNull()) return result->NotFound();
6309 ASSERT(proto->IsJSGlobalObject()); 6309 ASSERT(proto->IsJSGlobalObject());
6310 return JSReceiver::cast(proto)->LocalLookup( 6310 return JSReceiver::cast(proto)->LookupOwn(
6311 name, result, search_hidden_prototypes); 6311 name, result, search_hidden_prototypes);
6312 } 6312 }
6313 6313
6314 if (IsJSProxy()) { 6314 if (IsJSProxy()) {
6315 result->HandlerResult(JSProxy::cast(this)); 6315 result->HandlerResult(JSProxy::cast(this));
6316 return; 6316 return;
6317 } 6317 }
6318 6318
6319 // Do not use inline caching if the object is a non-global object 6319 // Do not use inline caching if the object is a non-global object
6320 // that requires access checks. 6320 // that requires access checks.
6321 if (IsAccessCheckNeeded()) { 6321 if (IsAccessCheckNeeded()) {
6322 result->DisallowCaching(); 6322 result->DisallowCaching();
6323 } 6323 }
6324 6324
6325 JSObject* js_object = JSObject::cast(this); 6325 JSObject* js_object = JSObject::cast(this);
6326 6326
6327 // Check for lookup interceptor except when bootstrapping. 6327 // Check for lookup interceptor except when bootstrapping.
6328 if (js_object->HasNamedInterceptor() && 6328 if (js_object->HasNamedInterceptor() &&
6329 !GetIsolate()->bootstrapper()->IsActive()) { 6329 !GetIsolate()->bootstrapper()->IsActive()) {
6330 result->InterceptorResult(js_object); 6330 result->InterceptorResult(js_object);
6331 return; 6331 return;
6332 } 6332 }
6333 6333
6334 js_object->LocalLookupRealNamedProperty(name, result); 6334 js_object->LookupOwnRealNamedProperty(name, result);
6335 if (result->IsFound() || !search_hidden_prototypes) return; 6335 if (result->IsFound() || !search_hidden_prototypes) return;
6336 6336
6337 Object* proto = js_object->GetPrototype(); 6337 Object* proto = js_object->GetPrototype();
6338 if (!proto->IsJSReceiver()) return; 6338 if (!proto->IsJSReceiver()) return;
6339 JSReceiver* receiver = JSReceiver::cast(proto); 6339 JSReceiver* receiver = JSReceiver::cast(proto);
6340 if (receiver->map()->is_hidden_prototype()) { 6340 if (receiver->map()->is_hidden_prototype()) {
6341 receiver->LocalLookup(name, result, search_hidden_prototypes); 6341 receiver->LookupOwn(name, result, search_hidden_prototypes);
6342 } 6342 }
6343 } 6343 }
6344 6344
6345 6345
6346 void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) { 6346 void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) {
6347 DisallowHeapAllocation no_gc; 6347 DisallowHeapAllocation no_gc;
6348 // Ecma-262 3rd 8.6.2.4 6348 // Ecma-262 3rd 8.6.2.4
6349 Handle<Object> null_value = GetIsolate()->factory()->null_value(); 6349 Handle<Object> null_value = GetIsolate()->factory()->null_value();
6350 for (Object* current = this; 6350 for (Object* current = this;
6351 current != *null_value; 6351 current != *null_value;
6352 current = JSObject::cast(current)->GetPrototype()) { 6352 current = JSObject::cast(current)->GetPrototype()) {
6353 JSReceiver::cast(current)->LocalLookup(name, result, false); 6353 JSReceiver::cast(current)->LookupOwn(name, result, false);
6354 if (result->IsFound()) return; 6354 if (result->IsFound()) return;
6355 } 6355 }
6356 result->NotFound(); 6356 result->NotFound();
6357 } 6357 }
6358 6358
6359 6359
6360 // Search object and its prototype chain for callback properties. 6360 // Search object and its prototype chain for callback properties.
6361 void JSObject::LookupCallbackProperty(Handle<Name> name, LookupResult* result) { 6361 void JSObject::LookupCallbackProperty(Handle<Name> name, LookupResult* result) {
6362 DisallowHeapAllocation no_gc; 6362 DisallowHeapAllocation no_gc;
6363 Handle<Object> null_value = GetIsolate()->factory()->null_value(); 6363 Handle<Object> null_value = GetIsolate()->factory()->null_value();
6364 for (Object* current = this; 6364 for (Object* current = this;
6365 current != *null_value && current->IsJSObject(); 6365 current != *null_value && current->IsJSObject();
6366 current = JSObject::cast(current)->GetPrototype()) { 6366 current = JSObject::cast(current)->GetPrototype()) {
6367 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); 6367 JSObject::cast(current)->LookupOwnRealNamedProperty(name, result);
6368 if (result->IsPropertyCallbacks()) return; 6368 if (result->IsPropertyCallbacks()) return;
6369 } 6369 }
6370 result->NotFound(); 6370 result->NotFound();
6371 } 6371 }
6372 6372
6373 6373
6374 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { 6374 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
6375 int len = array->length(); 6375 int len = array->length();
6376 for (int i = 0; i < len; i++) { 6376 for (int i = 0; i < len; i++) {
6377 Object* e = array->get(i); 6377 Object* e = array->get(i);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
6597 if (JSObject::GetKeysForNamedInterceptor( 6597 if (JSObject::GetKeysForNamedInterceptor(
6598 current, object).ToHandle(&result)) { 6598 current, object).ToHandle(&result)) {
6599 ASSIGN_RETURN_ON_EXCEPTION( 6599 ASSIGN_RETURN_ON_EXCEPTION(
6600 isolate, content, 6600 isolate, content,
6601 FixedArray::AddKeysFromArrayLike(content, result), 6601 FixedArray::AddKeysFromArrayLike(content, result),
6602 FixedArray); 6602 FixedArray);
6603 } 6603 }
6604 ASSERT(ContainsOnlyValidKeys(content)); 6604 ASSERT(ContainsOnlyValidKeys(content));
6605 } 6605 }
6606 6606
6607 // If we only want local properties we bail out after the first 6607 // If we only want own properties we bail out after the first
6608 // iteration. 6608 // iteration.
6609 if (type == LOCAL_ONLY) break; 6609 if (type == OWN_ONLY) break;
6610 } 6610 }
6611 return content; 6611 return content;
6612 } 6612 }
6613 6613
6614 6614
6615 // Try to update an accessor in an elements dictionary. Return true if the 6615 // Try to update an accessor in an elements dictionary. Return true if the
6616 // update succeeded, and false otherwise. 6616 // update succeeded, and false otherwise.
6617 static bool UpdateGetterSetterInDictionary( 6617 static bool UpdateGetterSetterInDictionary(
6618 SeededNumberDictionary* dictionary, 6618 SeededNumberDictionary* dictionary,
6619 uint32_t index, 6619 uint32_t index,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6704 accessors->set_access_flags(access_control); 6704 accessors->set_access_flags(access_control);
6705 6705
6706 SetElementCallback(object, index, accessors, attributes); 6706 SetElementCallback(object, index, accessors, attributes);
6707 } 6707 }
6708 6708
6709 6709
6710 Handle<AccessorPair> JSObject::CreateAccessorPairFor(Handle<JSObject> object, 6710 Handle<AccessorPair> JSObject::CreateAccessorPairFor(Handle<JSObject> object,
6711 Handle<Name> name) { 6711 Handle<Name> name) {
6712 Isolate* isolate = object->GetIsolate(); 6712 Isolate* isolate = object->GetIsolate();
6713 LookupResult result(isolate); 6713 LookupResult result(isolate);
6714 object->LocalLookupRealNamedProperty(name, &result); 6714 object->LookupOwnRealNamedProperty(name, &result);
6715 if (result.IsPropertyCallbacks()) { 6715 if (result.IsPropertyCallbacks()) {
6716 // Note that the result can actually have IsDontDelete() == true when we 6716 // Note that the result can actually have IsDontDelete() == true when we
6717 // e.g. have to fall back to the slow case while adding a setter after 6717 // e.g. have to fall back to the slow case while adding a setter after
6718 // successfully reusing a map transition for a getter. Nevertheless, this is 6718 // successfully reusing a map transition for a getter. Nevertheless, this is
6719 // OK, because the assertion only holds for the whole addition of both 6719 // OK, because the assertion only holds for the whole addition of both
6720 // accessors, not for the addition of each part. See first comment in 6720 // accessors, not for the addition of each part. See first comment in
6721 // DefinePropertyAccessor below. 6721 // DefinePropertyAccessor below.
6722 Object* obj = result.GetCallbackObject(); 6722 Object* obj = result.GetCallbackObject();
6723 if (obj->IsAccessorPair()) { 6723 if (obj->IsAccessorPair()) {
6724 return AccessorPair::Copy(handle(AccessorPair::cast(obj), isolate)); 6724 return AccessorPair::Copy(handle(AccessorPair::cast(obj), isolate));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
6911 6911
6912 uint32_t index = 0; 6912 uint32_t index = 0;
6913 bool is_element = name->AsArrayIndex(&index); 6913 bool is_element = name->AsArrayIndex(&index);
6914 6914
6915 Handle<Object> old_value = isolate->factory()->the_hole_value(); 6915 Handle<Object> old_value = isolate->factory()->the_hole_value();
6916 bool is_observed = object->map()->is_observed() && 6916 bool is_observed = object->map()->is_observed() &&
6917 *name != isolate->heap()->hidden_string(); 6917 *name != isolate->heap()->hidden_string();
6918 bool preexists = false; 6918 bool preexists = false;
6919 if (is_observed) { 6919 if (is_observed) {
6920 if (is_element) { 6920 if (is_element) {
6921 preexists = HasLocalElement(object, index); 6921 preexists = HasOwnElement(object, index);
6922 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) { 6922 if (preexists && GetOwnElementAccessorPair(object, index).is_null()) {
6923 old_value = 6923 old_value =
6924 Object::GetElement(isolate, object, index).ToHandleChecked(); 6924 Object::GetElement(isolate, object, index).ToHandleChecked();
6925 } 6925 }
6926 } else { 6926 } else {
6927 LookupResult lookup(isolate); 6927 LookupResult lookup(isolate);
6928 object->LocalLookup(name, &lookup, true); 6928 object->LookupOwn(name, &lookup, true);
6929 preexists = lookup.IsProperty(); 6929 preexists = lookup.IsProperty();
6930 if (preexists && lookup.IsDataProperty()) { 6930 if (preexists && lookup.IsDataProperty()) {
6931 old_value = 6931 old_value =
6932 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 6932 Object::GetPropertyOrElement(object, name).ToHandleChecked();
6933 } 6933 }
6934 } 6934 }
6935 } 6935 }
6936 6936
6937 if (is_element) { 6937 if (is_element) {
6938 DefineElementAccessor( 6938 DefineElementAccessor(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6979 6979
6980 6980
6981 bool JSObject::DefineFastAccessor(Handle<JSObject> object, 6981 bool JSObject::DefineFastAccessor(Handle<JSObject> object,
6982 Handle<Name> name, 6982 Handle<Name> name,
6983 AccessorComponent component, 6983 AccessorComponent component,
6984 Handle<Object> accessor, 6984 Handle<Object> accessor,
6985 PropertyAttributes attributes) { 6985 PropertyAttributes attributes) {
6986 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined()); 6986 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined());
6987 Isolate* isolate = object->GetIsolate(); 6987 Isolate* isolate = object->GetIsolate();
6988 LookupResult result(isolate); 6988 LookupResult result(isolate);
6989 object->LocalLookup(name, &result); 6989 object->LookupOwn(name, &result);
6990 6990
6991 if (result.IsFound() && !result.IsPropertyCallbacks()) { 6991 if (result.IsFound() && !result.IsPropertyCallbacks()) {
6992 return false; 6992 return false;
6993 } 6993 }
6994 6994
6995 // Return success if the same accessor with the same attributes already exist. 6995 // Return success if the same accessor with the same attributes already exist.
6996 AccessorPair* source_accessors = NULL; 6996 AccessorPair* source_accessors = NULL;
6997 if (result.IsPropertyCallbacks()) { 6997 if (result.IsPropertyCallbacks()) {
6998 Object* callback_value = result.GetCallbackObject(); 6998 Object* callback_value = result.GetCallbackObject();
6999 if (callback_value->IsAccessorPair()) { 6999 if (callback_value->IsAccessorPair()) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
7114 break; 7114 break;
7115 case SLOPPY_ARGUMENTS_ELEMENTS: 7115 case SLOPPY_ARGUMENTS_ELEMENTS:
7116 UNIMPLEMENTED(); 7116 UNIMPLEMENTED();
7117 break; 7117 break;
7118 } 7118 }
7119 7119
7120 SetElementCallback(object, index, info, info->property_attributes()); 7120 SetElementCallback(object, index, info, info->property_attributes());
7121 } else { 7121 } else {
7122 // Lookup the name. 7122 // Lookup the name.
7123 LookupResult result(isolate); 7123 LookupResult result(isolate);
7124 object->LocalLookup(name, &result, true); 7124 object->LookupOwn(name, &result, true);
7125 // ES5 forbids turning a property into an accessor if it's not 7125 // ES5 forbids turning a property into an accessor if it's not
7126 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). 7126 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
7127 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) { 7127 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
7128 return factory->undefined_value(); 7128 return factory->undefined_value();
7129 } 7129 }
7130 7130
7131 SetPropertyCallback(object, name, info, info->property_attributes()); 7131 SetPropertyCallback(object, name, info, info->property_attributes());
7132 } 7132 }
7133 7133
7134 return object; 7134 return object;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7170 isolate); 7170 isolate);
7171 } 7171 }
7172 } 7172 }
7173 } 7173 }
7174 } 7174 }
7175 } else { 7175 } else {
7176 for (Handle<Object> obj = object; 7176 for (Handle<Object> obj = object;
7177 !obj->IsNull(); 7177 !obj->IsNull();
7178 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { 7178 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
7179 LookupResult result(isolate); 7179 LookupResult result(isolate);
7180 JSReceiver::cast(*obj)->LocalLookup(name, &result); 7180 JSReceiver::cast(*obj)->LookupOwn(name, &result);
7181 if (result.IsFound()) { 7181 if (result.IsFound()) {
7182 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); 7182 if (result.IsReadOnly()) return isolate->factory()->undefined_value();
7183 if (result.IsPropertyCallbacks()) { 7183 if (result.IsPropertyCallbacks()) {
7184 Object* obj = result.GetCallbackObject(); 7184 Object* obj = result.GetCallbackObject();
7185 if (obj->IsAccessorPair()) { 7185 if (obj->IsAccessorPair()) {
7186 return handle(AccessorPair::cast(obj)->GetComponent(component), 7186 return handle(AccessorPair::cast(obj)->GetComponent(component),
7187 isolate); 7187 isolate);
7188 } 7188 }
7189 } 7189 }
7190 } 7190 }
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
8800 } 8800 }
8801 } 8801 }
8802 8802
8803 8803
8804 // Reserve space for statics needing saving and restoring. 8804 // Reserve space for statics needing saving and restoring.
8805 int Relocatable::ArchiveSpacePerThread() { 8805 int Relocatable::ArchiveSpacePerThread() {
8806 return sizeof(Relocatable*); // NOLINT 8806 return sizeof(Relocatable*); // NOLINT
8807 } 8807 }
8808 8808
8809 8809
8810 // Archive statics that are thread local. 8810 // Archive statics that are thread-local.
8811 char* Relocatable::ArchiveState(Isolate* isolate, char* to) { 8811 char* Relocatable::ArchiveState(Isolate* isolate, char* to) {
8812 *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top(); 8812 *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top();
8813 isolate->set_relocatable_top(NULL); 8813 isolate->set_relocatable_top(NULL);
8814 return to + ArchiveSpacePerThread(); 8814 return to + ArchiveSpacePerThread();
8815 } 8815 }
8816 8816
8817 8817
8818 // Restore statics that are thread local. 8818 // Restore statics that are thread-local.
8819 char* Relocatable::RestoreState(Isolate* isolate, char* from) { 8819 char* Relocatable::RestoreState(Isolate* isolate, char* from) {
8820 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from)); 8820 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
8821 return from + ArchiveSpacePerThread(); 8821 return from + ArchiveSpacePerThread();
8822 } 8822 }
8823 8823
8824 8824
8825 char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) { 8825 char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) {
8826 Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage); 8826 Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage);
8827 Iterate(v, top); 8827 Iterate(v, top);
8828 return thread_storage + ArchiveSpacePerThread(); 8828 return thread_storage + ArchiveSpacePerThread();
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after
11892 11892
11893 // Returns false if the passed-in index is marked non-configurable, 11893 // Returns false if the passed-in index is marked non-configurable,
11894 // which will cause the ES5 truncation operation to halt, and thus 11894 // which will cause the ES5 truncation operation to halt, and thus
11895 // no further old values need be collected. 11895 // no further old values need be collected.
11896 static bool GetOldValue(Isolate* isolate, 11896 static bool GetOldValue(Isolate* isolate,
11897 Handle<JSObject> object, 11897 Handle<JSObject> object,
11898 uint32_t index, 11898 uint32_t index,
11899 List<Handle<Object> >* old_values, 11899 List<Handle<Object> >* old_values,
11900 List<uint32_t>* indices) { 11900 List<uint32_t>* indices) {
11901 PropertyAttributes attributes = 11901 PropertyAttributes attributes =
11902 JSReceiver::GetLocalElementAttribute(object, index); 11902 JSReceiver::GetOwnElementAttribute(object, index);
11903 ASSERT(attributes != ABSENT); 11903 ASSERT(attributes != ABSENT);
11904 if (attributes == DONT_DELETE) return false; 11904 if (attributes == DONT_DELETE) return false;
11905 Handle<Object> value; 11905 Handle<Object> value;
11906 if (!JSObject::GetLocalElementAccessorPair(object, index).is_null()) { 11906 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) {
11907 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); 11907 value = Handle<Object>::cast(isolate->factory()->the_hole_value());
11908 } else { 11908 } else {
11909 value = Object::GetElement(isolate, object, index).ToHandleChecked(); 11909 value = Object::GetElement(isolate, object, index).ToHandleChecked();
11910 } 11910 }
11911 old_values->Add(value); 11911 old_values->Add(value);
11912 indices->Add(index); 11912 indices->Add(index);
11913 return true; 11913 return true;
11914 } 11914 }
11915 11915
11916 static void EnqueueSpliceRecord(Handle<JSArray> object, 11916 static void EnqueueSpliceRecord(Handle<JSArray> object,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
11972 Isolate* isolate = array->GetIsolate(); 11972 Isolate* isolate = array->GetIsolate();
11973 List<uint32_t> indices; 11973 List<uint32_t> indices;
11974 List<Handle<Object> > old_values; 11974 List<Handle<Object> > old_values;
11975 Handle<Object> old_length_handle(array->length(), isolate); 11975 Handle<Object> old_length_handle(array->length(), isolate);
11976 uint32_t old_length = 0; 11976 uint32_t old_length = 0;
11977 CHECK(old_length_handle->ToArrayIndex(&old_length)); 11977 CHECK(old_length_handle->ToArrayIndex(&old_length));
11978 uint32_t new_length = 0; 11978 uint32_t new_length = 0;
11979 CHECK(new_length_handle->ToArrayIndex(&new_length)); 11979 CHECK(new_length_handle->ToArrayIndex(&new_length));
11980 11980
11981 static const PropertyAttributes kNoAttrFilter = NONE; 11981 static const PropertyAttributes kNoAttrFilter = NONE;
11982 int num_elements = array->NumberOfLocalElements(kNoAttrFilter); 11982 int num_elements = array->NumberOfOwnElements(kNoAttrFilter);
11983 if (num_elements > 0) { 11983 if (num_elements > 0) {
11984 if (old_length == static_cast<uint32_t>(num_elements)) { 11984 if (old_length == static_cast<uint32_t>(num_elements)) {
11985 // Simple case for arrays without holes. 11985 // Simple case for arrays without holes.
11986 for (uint32_t i = old_length - 1; i + 1 > new_length; --i) { 11986 for (uint32_t i = old_length - 1; i + 1 > new_length; --i) {
11987 if (!GetOldValue(isolate, array, i, &old_values, &indices)) break; 11987 if (!GetOldValue(isolate, array, i, &old_values, &indices)) break;
11988 } 11988 }
11989 } else { 11989 } else {
11990 // For sparse arrays, only iterate over existing elements. 11990 // For sparse arrays, only iterate over existing elements.
11991 // TODO(rafaelw): For fast, sparse arrays, we can avoid iterating over 11991 // TODO(rafaelw): For fast, sparse arrays, we can avoid iterating over
11992 // the to-be-removed indices twice. 11992 // the to-be-removed indices twice.
11993 Handle<FixedArray> keys = isolate->factory()->NewFixedArray(num_elements); 11993 Handle<FixedArray> keys = isolate->factory()->NewFixedArray(num_elements);
11994 array->GetLocalElementKeys(*keys, kNoAttrFilter); 11994 array->GetOwnElementKeys(*keys, kNoAttrFilter);
11995 while (num_elements-- > 0) { 11995 while (num_elements-- > 0) {
11996 uint32_t index = NumberToUint32(keys->get(num_elements)); 11996 uint32_t index = NumberToUint32(keys->get(num_elements));
11997 if (index < new_length) break; 11997 if (index < new_length) break;
11998 if (!GetOldValue(isolate, array, index, &old_values, &indices)) break; 11998 if (!GetOldValue(isolate, array, index, &old_values, &indices)) break;
11999 } 11999 }
12000 } 12000 }
12001 } 12001 }
12002 12002
12003 Handle<Object> hresult; 12003 Handle<Object> hresult;
12004 ASSIGN_RETURN_ON_EXCEPTION( 12004 ASSIGN_RETURN_ON_EXCEPTION(
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
12477 uint32_t arg_count, 12477 uint32_t arg_count,
12478 EnsureElementsMode mode) { 12478 EnsureElementsMode mode) {
12479 // Elements in |Arguments| are ordered backwards (because they're on the 12479 // Elements in |Arguments| are ordered backwards (because they're on the
12480 // stack), but the method that's called here iterates over them in forward 12480 // stack), but the method that's called here iterates over them in forward
12481 // direction. 12481 // direction.
12482 return EnsureCanContainElements( 12482 return EnsureCanContainElements(
12483 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); 12483 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode);
12484 } 12484 }
12485 12485
12486 12486
12487 MaybeHandle<AccessorPair> JSObject::GetLocalPropertyAccessorPair( 12487 MaybeHandle<AccessorPair> JSObject::GetOwnPropertyAccessorPair(
12488 Handle<JSObject> object, 12488 Handle<JSObject> object,
12489 Handle<Name> name) { 12489 Handle<Name> name) {
12490 uint32_t index = 0; 12490 uint32_t index = 0;
12491 if (name->AsArrayIndex(&index)) { 12491 if (name->AsArrayIndex(&index)) {
12492 return GetLocalElementAccessorPair(object, index); 12492 return GetOwnElementAccessorPair(object, index);
12493 } 12493 }
12494 12494
12495 Isolate* isolate = object->GetIsolate(); 12495 Isolate* isolate = object->GetIsolate();
12496 LookupResult lookup(isolate); 12496 LookupResult lookup(isolate);
12497 object->LocalLookupRealNamedProperty(name, &lookup); 12497 object->LookupOwnRealNamedProperty(name, &lookup);
12498 12498
12499 if (lookup.IsPropertyCallbacks() && 12499 if (lookup.IsPropertyCallbacks() &&
12500 lookup.GetCallbackObject()->IsAccessorPair()) { 12500 lookup.GetCallbackObject()->IsAccessorPair()) {
12501 return handle(AccessorPair::cast(lookup.GetCallbackObject()), isolate); 12501 return handle(AccessorPair::cast(lookup.GetCallbackObject()), isolate);
12502 } 12502 }
12503 return MaybeHandle<AccessorPair>(); 12503 return MaybeHandle<AccessorPair>();
12504 } 12504 }
12505 12505
12506 12506
12507 MaybeHandle<AccessorPair> JSObject::GetLocalElementAccessorPair( 12507 MaybeHandle<AccessorPair> JSObject::GetOwnElementAccessorPair(
12508 Handle<JSObject> object, 12508 Handle<JSObject> object,
12509 uint32_t index) { 12509 uint32_t index) {
12510 if (object->IsJSGlobalProxy()) { 12510 if (object->IsJSGlobalProxy()) {
12511 Handle<Object> proto(object->GetPrototype(), object->GetIsolate()); 12511 Handle<Object> proto(object->GetPrototype(), object->GetIsolate());
12512 if (proto->IsNull()) return MaybeHandle<AccessorPair>(); 12512 if (proto->IsNull()) return MaybeHandle<AccessorPair>();
12513 ASSERT(proto->IsJSGlobalObject()); 12513 ASSERT(proto->IsJSGlobalObject());
12514 return GetLocalElementAccessorPair(Handle<JSObject>::cast(proto), index); 12514 return GetOwnElementAccessorPair(Handle<JSObject>::cast(proto), index);
12515 } 12515 }
12516 12516
12517 // Check for lookup interceptor. 12517 // Check for lookup interceptor.
12518 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); 12518 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>();
12519 12519
12520 return object->GetElementsAccessor()->GetAccessorPair(object, object, index); 12520 return object->GetElementsAccessor()->GetAccessorPair(object, object, index);
12521 } 12521 }
12522 12522
12523 12523
12524 MaybeHandle<Object> JSObject::SetElementWithInterceptor( 12524 MaybeHandle<Object> JSObject::SetElementWithInterceptor(
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
13142 13142
13143 if (!object->map()->is_observed()) { 13143 if (!object->map()->is_observed()) {
13144 return object->HasIndexedInterceptor() 13144 return object->HasIndexedInterceptor()
13145 ? SetElementWithInterceptor(object, index, value, attributes, 13145 ? SetElementWithInterceptor(object, index, value, attributes,
13146 strict_mode, check_prototype, set_mode) 13146 strict_mode, check_prototype, set_mode)
13147 : SetElementWithoutInterceptor(object, index, value, attributes, 13147 : SetElementWithoutInterceptor(object, index, value, attributes,
13148 strict_mode, check_prototype, set_mode); 13148 strict_mode, check_prototype, set_mode);
13149 } 13149 }
13150 13150
13151 PropertyAttributes old_attributes = 13151 PropertyAttributes old_attributes =
13152 JSReceiver::GetLocalElementAttribute(object, index); 13152 JSReceiver::GetOwnElementAttribute(object, index);
13153 Handle<Object> old_value = isolate->factory()->the_hole_value(); 13153 Handle<Object> old_value = isolate->factory()->the_hole_value();
13154 Handle<Object> old_length_handle; 13154 Handle<Object> old_length_handle;
13155 Handle<Object> new_length_handle; 13155 Handle<Object> new_length_handle;
13156 13156
13157 if (old_attributes != ABSENT) { 13157 if (old_attributes != ABSENT) {
13158 if (GetLocalElementAccessorPair(object, index).is_null()) { 13158 if (GetOwnElementAccessorPair(object, index).is_null()) {
13159 old_value = Object::GetElement(isolate, object, index).ToHandleChecked(); 13159 old_value = Object::GetElement(isolate, object, index).ToHandleChecked();
13160 } 13160 }
13161 } else if (object->IsJSArray()) { 13161 } else if (object->IsJSArray()) {
13162 // Store old array length in case adding an element grows the array. 13162 // Store old array length in case adding an element grows the array.
13163 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), 13163 old_length_handle = handle(Handle<JSArray>::cast(object)->length(),
13164 isolate); 13164 isolate);
13165 } 13165 }
13166 13166
13167 // Check for lookup interceptor 13167 // Check for lookup interceptor
13168 Handle<Object> result; 13168 Handle<Object> result;
13169 ASSIGN_RETURN_ON_EXCEPTION( 13169 ASSIGN_RETURN_ON_EXCEPTION(
13170 isolate, result, 13170 isolate, result,
13171 object->HasIndexedInterceptor() 13171 object->HasIndexedInterceptor()
13172 ? SetElementWithInterceptor( 13172 ? SetElementWithInterceptor(
13173 object, index, value, attributes, 13173 object, index, value, attributes,
13174 strict_mode, check_prototype, set_mode) 13174 strict_mode, check_prototype, set_mode)
13175 : SetElementWithoutInterceptor( 13175 : SetElementWithoutInterceptor(
13176 object, index, value, attributes, 13176 object, index, value, attributes,
13177 strict_mode, check_prototype, set_mode), 13177 strict_mode, check_prototype, set_mode),
13178 Object); 13178 Object);
13179 13179
13180 Handle<String> name = isolate->factory()->Uint32ToString(index); 13180 Handle<String> name = isolate->factory()->Uint32ToString(index);
13181 PropertyAttributes new_attributes = GetLocalElementAttribute(object, index); 13181 PropertyAttributes new_attributes = GetOwnElementAttribute(object, index);
13182 if (old_attributes == ABSENT) { 13182 if (old_attributes == ABSENT) {
13183 if (object->IsJSArray() && 13183 if (object->IsJSArray() &&
13184 !old_length_handle->SameValue( 13184 !old_length_handle->SameValue(
13185 Handle<JSArray>::cast(object)->length())) { 13185 Handle<JSArray>::cast(object)->length())) {
13186 new_length_handle = handle(Handle<JSArray>::cast(object)->length(), 13186 new_length_handle = handle(Handle<JSArray>::cast(object)->length(),
13187 isolate); 13187 isolate);
13188 uint32_t old_length = 0; 13188 uint32_t old_length = 0;
13189 uint32_t new_length = 0; 13189 uint32_t new_length = 0;
13190 CHECK(old_length_handle->ToArrayIndex(&old_length)); 13190 CHECK(old_length_handle->ToArrayIndex(&old_length));
13191 CHECK(new_length_handle->ToArrayIndex(&new_length)); 13191 CHECK(new_length_handle->ToArrayIndex(&new_length));
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
13808 constructor->shared()->get_api_func_data()->indexed_property_handler(); 13808 constructor->shared()->get_api_func_data()->indexed_property_handler();
13809 return InterceptorInfo::cast(result); 13809 return InterceptorInfo::cast(result);
13810 } 13810 }
13811 13811
13812 13812
13813 MaybeHandle<Object> JSObject::GetPropertyPostInterceptor( 13813 MaybeHandle<Object> JSObject::GetPropertyPostInterceptor(
13814 Handle<JSObject> object, 13814 Handle<JSObject> object,
13815 Handle<Object> receiver, 13815 Handle<Object> receiver,
13816 Handle<Name> name, 13816 Handle<Name> name,
13817 PropertyAttributes* attributes) { 13817 PropertyAttributes* attributes) {
13818 // Check local property in holder, ignore interceptor. 13818 // Check own property in holder, ignore interceptor.
13819 Isolate* isolate = object->GetIsolate(); 13819 Isolate* isolate = object->GetIsolate();
13820 LookupResult lookup(isolate); 13820 LookupResult lookup(isolate);
13821 object->LocalLookupRealNamedProperty(name, &lookup); 13821 object->LookupOwnRealNamedProperty(name, &lookup);
13822 if (lookup.IsFound()) { 13822 if (lookup.IsFound()) {
13823 return GetProperty(object, receiver, &lookup, name, attributes); 13823 return GetProperty(object, receiver, &lookup, name, attributes);
13824 } else { 13824 } else {
13825 // Continue searching via the prototype chain. 13825 // Continue searching via the prototype chain.
13826 Handle<Object> prototype(object->GetPrototype(), isolate); 13826 Handle<Object> prototype(object->GetPrototype(), isolate);
13827 *attributes = ABSENT; 13827 *attributes = ABSENT;
13828 if (prototype->IsNull()) return isolate->factory()->undefined_value(); 13828 if (prototype->IsNull()) return isolate->factory()->undefined_value();
13829 return GetPropertyWithReceiver(prototype, receiver, name, attributes); 13829 return GetPropertyWithReceiver(prototype, receiver, name, attributes);
13830 } 13830 }
13831 } 13831 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
13925 // Check access rights if needed. 13925 // Check access rights if needed.
13926 if (object->IsAccessCheckNeeded()) { 13926 if (object->IsAccessCheckNeeded()) {
13927 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { 13927 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
13928 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); 13928 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
13929 // TODO(yangguo): Issue 3269, check for scheduled exception missing? 13929 // TODO(yangguo): Issue 3269, check for scheduled exception missing?
13930 return false; 13930 return false;
13931 } 13931 }
13932 } 13932 }
13933 13933
13934 LookupResult result(isolate); 13934 LookupResult result(isolate);
13935 object->LocalLookupRealNamedProperty(key, &result); 13935 object->LookupOwnRealNamedProperty(key, &result);
13936 return result.IsFound() && !result.IsInterceptor(); 13936 return result.IsFound() && !result.IsInterceptor();
13937 } 13937 }
13938 13938
13939 13939
13940 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { 13940 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) {
13941 Isolate* isolate = object->GetIsolate(); 13941 Isolate* isolate = object->GetIsolate();
13942 HandleScope scope(isolate); 13942 HandleScope scope(isolate);
13943 // Check access rights if needed. 13943 // Check access rights if needed.
13944 if (object->IsAccessCheckNeeded()) { 13944 if (object->IsAccessCheckNeeded()) {
13945 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { 13945 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) {
(...skipping 23 matching lines...) Expand all
13969 // Check access rights if needed. 13969 // Check access rights if needed.
13970 if (object->IsAccessCheckNeeded()) { 13970 if (object->IsAccessCheckNeeded()) {
13971 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { 13971 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
13972 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); 13972 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
13973 // TODO(yangguo): Issue 3269, check for scheduled exception missing? 13973 // TODO(yangguo): Issue 3269, check for scheduled exception missing?
13974 return false; 13974 return false;
13975 } 13975 }
13976 } 13976 }
13977 13977
13978 LookupResult result(isolate); 13978 LookupResult result(isolate);
13979 object->LocalLookupRealNamedProperty(key, &result); 13979 object->LookupOwnRealNamedProperty(key, &result);
13980 return result.IsPropertyCallbacks(); 13980 return result.IsPropertyCallbacks();
13981 } 13981 }
13982 13982
13983 13983
13984 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { 13984 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) {
13985 if (HasFastProperties()) { 13985 if (HasFastProperties()) {
13986 Map* map = this->map(); 13986 Map* map = this->map();
13987 if (filter == NONE) return map->NumberOfOwnDescriptors(); 13987 if (filter == NONE) return map->NumberOfOwnDescriptors();
13988 if (filter & DONT_ENUM) { 13988 if (filter & DONT_ENUM) {
13989 int result = map->EnumLength(); 13989 int result = map->EnumLength();
13990 if (result != kInvalidEnumCacheSentinel) return result; 13990 if (result != kInvalidEnumCacheSentinel) return result;
13991 } 13991 }
13992 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter); 13992 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter);
13993 } 13993 }
13994 return property_dictionary()->NumberOfElementsFilterAttributes(filter); 13994 return property_dictionary()->NumberOfElementsFilterAttributes(filter);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
14101 SwapPairs(numbers, i, p); 14101 SwapPairs(numbers, i, p);
14102 } 14102 }
14103 } 14103 }
14104 } else { 14104 } else {
14105 HeapSortPairs(this, numbers, len); 14105 HeapSortPairs(this, numbers, len);
14106 return; 14106 return;
14107 } 14107 }
14108 } 14108 }
14109 14109
14110 14110
14111 // Fill in the names of local properties into the supplied storage. The main 14111 // Fill in the names of own properties into the supplied storage. The main
14112 // purpose of this function is to provide reflection information for the object 14112 // purpose of this function is to provide reflection information for the object
14113 // mirrors. 14113 // mirrors.
14114 void JSObject::GetLocalPropertyNames( 14114 void JSObject::GetOwnPropertyNames(
14115 FixedArray* storage, int index, PropertyAttributes filter) { 14115 FixedArray* storage, int index, PropertyAttributes filter) {
14116 ASSERT(storage->length() >= (NumberOfLocalProperties(filter) - index)); 14116 ASSERT(storage->length() >= (NumberOfOwnProperties(filter) - index));
14117 if (HasFastProperties()) { 14117 if (HasFastProperties()) {
14118 int real_size = map()->NumberOfOwnDescriptors(); 14118 int real_size = map()->NumberOfOwnDescriptors();
14119 DescriptorArray* descs = map()->instance_descriptors(); 14119 DescriptorArray* descs = map()->instance_descriptors();
14120 for (int i = 0; i < real_size; i++) { 14120 for (int i = 0; i < real_size; i++) {
14121 if ((descs->GetDetails(i).attributes() & filter) == 0 && 14121 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
14122 !FilterKey(descs->GetKey(i), filter)) { 14122 !FilterKey(descs->GetKey(i), filter)) {
14123 storage->set(index++, descs->GetKey(i)); 14123 storage->set(index++, descs->GetKey(i));
14124 } 14124 }
14125 } 14125 }
14126 } else { 14126 } else {
14127 property_dictionary()->CopyKeysTo(storage, 14127 property_dictionary()->CopyKeysTo(storage,
14128 index, 14128 index,
14129 filter, 14129 filter,
14130 NameDictionary::UNSORTED); 14130 NameDictionary::UNSORTED);
14131 } 14131 }
14132 } 14132 }
14133 14133
14134 14134
14135 int JSObject::NumberOfLocalElements(PropertyAttributes filter) { 14135 int JSObject::NumberOfOwnElements(PropertyAttributes filter) {
14136 return GetLocalElementKeys(NULL, filter); 14136 return GetOwnElementKeys(NULL, filter);
14137 } 14137 }
14138 14138
14139 14139
14140 int JSObject::NumberOfEnumElements() { 14140 int JSObject::NumberOfEnumElements() {
14141 // Fast case for objects with no elements. 14141 // Fast case for objects with no elements.
14142 if (!IsJSValue() && HasFastObjectElements()) { 14142 if (!IsJSValue() && HasFastObjectElements()) {
14143 uint32_t length = IsJSArray() ? 14143 uint32_t length = IsJSArray() ?
14144 static_cast<uint32_t>( 14144 static_cast<uint32_t>(
14145 Smi::cast(JSArray::cast(this)->length())->value()) : 14145 Smi::cast(JSArray::cast(this)->length())->value()) :
14146 static_cast<uint32_t>(FixedArray::cast(elements())->length()); 14146 static_cast<uint32_t>(FixedArray::cast(elements())->length());
14147 if (length == 0) return 0; 14147 if (length == 0) return 0;
14148 } 14148 }
14149 // Compute the number of enumerable elements. 14149 // Compute the number of enumerable elements.
14150 return NumberOfLocalElements(static_cast<PropertyAttributes>(DONT_ENUM)); 14150 return NumberOfOwnElements(static_cast<PropertyAttributes>(DONT_ENUM));
14151 } 14151 }
14152 14152
14153 14153
14154 int JSObject::GetLocalElementKeys(FixedArray* storage, 14154 int JSObject::GetOwnElementKeys(FixedArray* storage,
14155 PropertyAttributes filter) { 14155 PropertyAttributes filter) {
14156 int counter = 0; 14156 int counter = 0;
14157 switch (GetElementsKind()) { 14157 switch (GetElementsKind()) {
14158 case FAST_SMI_ELEMENTS: 14158 case FAST_SMI_ELEMENTS:
14159 case FAST_ELEMENTS: 14159 case FAST_ELEMENTS:
14160 case FAST_HOLEY_SMI_ELEMENTS: 14160 case FAST_HOLEY_SMI_ELEMENTS:
14161 case FAST_HOLEY_ELEMENTS: { 14161 case FAST_HOLEY_ELEMENTS: {
14162 int length = IsJSArray() ? 14162 int length = IsJSArray() ?
14163 Smi::cast(JSArray::cast(this)->length())->value() : 14163 Smi::cast(JSArray::cast(this)->length())->value() :
14164 FixedArray::cast(elements())->length(); 14164 FixedArray::cast(elements())->length();
14165 for (int i = 0; i < length; i++) { 14165 for (int i = 0; i < length; i++) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
14271 } 14271 }
14272 counter += str->length(); 14272 counter += str->length();
14273 } 14273 }
14274 } 14274 }
14275 ASSERT(!storage || storage->length() == counter); 14275 ASSERT(!storage || storage->length() == counter);
14276 return counter; 14276 return counter;
14277 } 14277 }
14278 14278
14279 14279
14280 int JSObject::GetEnumElementKeys(FixedArray* storage) { 14280 int JSObject::GetEnumElementKeys(FixedArray* storage) {
14281 return GetLocalElementKeys(storage, 14281 return GetOwnElementKeys(storage, static_cast<PropertyAttributes>(DONT_ENUM));
14282 static_cast<PropertyAttributes>(DONT_ENUM));
14283 } 14282 }
14284 14283
14285 14284
14286 // StringKey simply carries a string object as key. 14285 // StringKey simply carries a string object as key.
14287 class StringKey : public HashTableKey { 14286 class StringKey : public HashTableKey {
14288 public: 14287 public:
14289 explicit StringKey(String* string) : 14288 explicit StringKey(String* string) :
14290 string_(string), 14289 string_(string),
14291 hash_(HashForObject(string)) { } 14290 hash_(HashForObject(string)) { }
14292 14291
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after
17014 ASSERT(index != kDateValue); 17013 ASSERT(index != kDateValue);
17015 17014
17016 DateCache* date_cache = GetIsolate()->date_cache(); 17015 DateCache* date_cache = GetIsolate()->date_cache();
17017 17016
17018 if (index < kFirstUncachedField) { 17017 if (index < kFirstUncachedField) {
17019 Object* stamp = cache_stamp(); 17018 Object* stamp = cache_stamp();
17020 if (stamp != date_cache->stamp() && stamp->IsSmi()) { 17019 if (stamp != date_cache->stamp() && stamp->IsSmi()) {
17021 // Since the stamp is not NaN, the value is also not NaN. 17020 // Since the stamp is not NaN, the value is also not NaN.
17022 int64_t local_time_ms = 17021 int64_t local_time_ms =
17023 date_cache->ToLocal(static_cast<int64_t>(value()->Number())); 17022 date_cache->ToLocal(static_cast<int64_t>(value()->Number()));
17024 SetLocalFields(local_time_ms, date_cache); 17023 SetCachedFields(local_time_ms, date_cache);
17025 } 17024 }
17026 switch (index) { 17025 switch (index) {
17027 case kYear: return year(); 17026 case kYear: return year();
17028 case kMonth: return month(); 17027 case kMonth: return month();
17029 case kDay: return day(); 17028 case kDay: return day();
17030 case kWeekday: return weekday(); 17029 case kWeekday: return weekday();
17031 case kHour: return hour(); 17030 case kHour: return hour();
17032 case kMinute: return min(); 17031 case kMinute: return min();
17033 case kSecond: return sec(); 17032 case kSecond: return sec();
17034 default: UNREACHABLE(); 17033 default: UNREACHABLE();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
17107 set_hour(nan, SKIP_WRITE_BARRIER); 17106 set_hour(nan, SKIP_WRITE_BARRIER);
17108 set_min(nan, SKIP_WRITE_BARRIER); 17107 set_min(nan, SKIP_WRITE_BARRIER);
17109 set_sec(nan, SKIP_WRITE_BARRIER); 17108 set_sec(nan, SKIP_WRITE_BARRIER);
17110 set_weekday(nan, SKIP_WRITE_BARRIER); 17109 set_weekday(nan, SKIP_WRITE_BARRIER);
17111 } else { 17110 } else {
17112 set_cache_stamp(Smi::FromInt(DateCache::kInvalidStamp), SKIP_WRITE_BARRIER); 17111 set_cache_stamp(Smi::FromInt(DateCache::kInvalidStamp), SKIP_WRITE_BARRIER);
17113 } 17112 }
17114 } 17113 }
17115 17114
17116 17115
17117 void JSDate::SetLocalFields(int64_t local_time_ms, DateCache* date_cache) { 17116 void JSDate::SetCachedFields(int64_t local_time_ms, DateCache* date_cache) {
17118 int days = DateCache::DaysFromTime(local_time_ms); 17117 int days = DateCache::DaysFromTime(local_time_ms);
17119 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days); 17118 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days);
17120 int year, month, day; 17119 int year, month, day;
17121 date_cache->YearMonthDayFromDays(days, &year, &month, &day); 17120 date_cache->YearMonthDayFromDays(days, &year, &month, &day);
17122 int weekday = date_cache->Weekday(days); 17121 int weekday = date_cache->Weekday(days);
17123 int hour = time_in_day_ms / (60 * 60 * 1000); 17122 int hour = time_in_day_ms / (60 * 60 * 1000);
17124 int min = (time_in_day_ms / (60 * 1000)) % 60; 17123 int min = (time_in_day_ms / (60 * 1000)) % 60;
17125 int sec = (time_in_day_ms / 1000) % 60; 17124 int sec = (time_in_day_ms / 1000) % 60;
17126 set_cache_stamp(date_cache->stamp()); 17125 set_cache_stamp(date_cache->stamp());
17127 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 17126 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
17282 #define ERROR_MESSAGES_TEXTS(C, T) T, 17281 #define ERROR_MESSAGES_TEXTS(C, T) T,
17283 static const char* error_messages_[] = { 17282 static const char* error_messages_[] = {
17284 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17283 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17285 }; 17284 };
17286 #undef ERROR_MESSAGES_TEXTS 17285 #undef ERROR_MESSAGES_TEXTS
17287 return error_messages_[reason]; 17286 return error_messages_[reason];
17288 } 17287 }
17289 17288
17290 17289
17291 } } // namespace v8::internal 17290 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698