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

Side by Side Diff: src/objects.cc

Issue 253843006: Object::Lookup(), JSObject::*Lookup*() and JSReceiver::*Lookup*() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review comments 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/runtime.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 "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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Object* fun = this; 93 Object* fun = this;
94 while (fun->IsJSFunctionProxy()) { 94 while (fun->IsJSFunctionProxy()) {
95 fun = JSFunctionProxy::cast(fun)->call_trap(); 95 fun = JSFunctionProxy::cast(fun)->call_trap();
96 } 96 }
97 return fun->IsJSFunction() || 97 return fun->IsJSFunction() ||
98 (fun->IsHeapObject() && 98 (fun->IsHeapObject() &&
99 HeapObject::cast(fun)->map()->has_instance_call_handler()); 99 HeapObject::cast(fun)->map()->has_instance_call_handler());
100 } 100 }
101 101
102 102
103 void Object::Lookup(Name* name, LookupResult* result) { 103 void Object::Lookup(Handle<Name> name, LookupResult* result) {
104 DisallowHeapAllocation no_gc;
104 Object* holder = NULL; 105 Object* holder = NULL;
105 if (IsJSReceiver()) { 106 if (IsJSReceiver()) {
106 holder = this; 107 holder = this;
107 } else { 108 } else {
108 Context* native_context = result->isolate()->context()->native_context(); 109 Context* native_context = result->isolate()->context()->native_context();
109 if (IsNumber()) { 110 if (IsNumber()) {
110 holder = native_context->number_function()->instance_prototype(); 111 holder = native_context->number_function()->instance_prototype();
111 } else if (IsString()) { 112 } else if (IsString()) {
112 holder = native_context->string_function()->instance_prototype(); 113 holder = native_context->string_function()->instance_prototype();
113 } else if (IsSymbol()) { 114 } else if (IsSymbol()) {
114 holder = native_context->symbol_function()->instance_prototype(); 115 holder = native_context->symbol_function()->instance_prototype();
115 } else if (IsBoolean()) { 116 } else if (IsBoolean()) {
116 holder = native_context->boolean_function()->instance_prototype(); 117 holder = native_context->boolean_function()->instance_prototype();
117 } else { 118 } else {
118 result->isolate()->PushStackTraceAndDie( 119 result->isolate()->PushStackTraceAndDie(
119 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001); 120 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001);
120 } 121 }
121 } 122 }
122 ASSERT(holder != NULL); // Cannot handle null or undefined. 123 ASSERT(holder != NULL); // Cannot handle null or undefined.
123 JSReceiver::cast(holder)->Lookup(name, result); 124 JSReceiver::cast(holder)->Lookup(name, result);
124 } 125 }
125 126
126 127
127 MaybeHandle<Object> Object::GetPropertyWithReceiver( 128 MaybeHandle<Object> Object::GetPropertyWithReceiver(
128 Handle<Object> object, 129 Handle<Object> object,
129 Handle<Object> receiver, 130 Handle<Object> receiver,
130 Handle<Name> name, 131 Handle<Name> name,
131 PropertyAttributes* attributes) { 132 PropertyAttributes* attributes) {
132 LookupResult lookup(name->GetIsolate()); 133 LookupResult lookup(name->GetIsolate());
133 object->Lookup(*name, &lookup); 134 object->Lookup(name, &lookup);
134 MaybeHandle<Object> result = 135 MaybeHandle<Object> result =
135 GetProperty(object, receiver, &lookup, name, attributes); 136 GetProperty(object, receiver, &lookup, name, attributes);
136 ASSERT(*attributes <= ABSENT); 137 ASSERT(*attributes <= ABSENT);
137 return result; 138 return result;
138 } 139 }
139 140
140 141
141 bool Object::ToInt32(int32_t* value) { 142 bool Object::ToInt32(int32_t* value) {
142 if (IsSmi()) { 143 if (IsSmi()) {
143 *value = Smi::cast(this)->value(); 144 *value = Smi::cast(this)->value();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 break; 477 break;
477 } 478 }
478 Handle<JSObject> holder(result->holder(), isolate); 479 Handle<JSObject> holder(result->holder(), isolate);
479 return GetPropertyWithCallback(holder, receiver, callback_obj, name); 480 return GetPropertyWithCallback(holder, receiver, callback_obj, name);
480 } 481 }
481 case NORMAL: 482 case NORMAL:
482 case FIELD: 483 case FIELD:
483 case CONSTANT: { 484 case CONSTANT: {
484 // Search ALL_CAN_READ accessors in prototype chain. 485 // Search ALL_CAN_READ accessors in prototype chain.
485 LookupResult r(isolate); 486 LookupResult r(isolate);
486 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r); 487 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
487 if (r.IsProperty()) { 488 if (r.IsProperty()) {
488 return GetPropertyWithFailedAccessCheck( 489 return GetPropertyWithFailedAccessCheck(
489 object, receiver, &r, name, attributes); 490 object, receiver, &r, name, attributes);
490 } 491 }
491 break; 492 break;
492 } 493 }
493 case INTERCEPTOR: { 494 case INTERCEPTOR: {
494 // If the object has an interceptor, try real named properties. 495 // If the object has an interceptor, try real named properties.
495 // No access check in GetPropertyAttributeWithInterceptor. 496 // No access check in GetPropertyAttributeWithInterceptor.
496 LookupResult r(isolate); 497 LookupResult r(isolate);
497 result->holder()->LookupRealNamedProperty(*name, &r); 498 result->holder()->LookupRealNamedProperty(name, &r);
498 if (r.IsProperty()) { 499 if (r.IsProperty()) {
499 return GetPropertyWithFailedAccessCheck( 500 return GetPropertyWithFailedAccessCheck(
500 object, receiver, &r, name, attributes); 501 object, receiver, &r, name, attributes);
501 } 502 }
502 break; 503 break;
503 } 504 }
504 default: 505 default:
505 UNREACHABLE(); 506 UNREACHABLE();
506 } 507 }
507 } 508 }
(...skipping 29 matching lines...) Expand all
537 } 538 }
538 break; 539 break;
539 } 540 }
540 541
541 case NORMAL: 542 case NORMAL:
542 case FIELD: 543 case FIELD:
543 case CONSTANT: { 544 case CONSTANT: {
544 if (!continue_search) break; 545 if (!continue_search) break;
545 // Search ALL_CAN_READ accessors in prototype chain. 546 // Search ALL_CAN_READ accessors in prototype chain.
546 LookupResult r(object->GetIsolate()); 547 LookupResult r(object->GetIsolate());
547 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r); 548 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
548 if (r.IsProperty()) { 549 if (r.IsProperty()) {
549 return GetPropertyAttributeWithFailedAccessCheck( 550 return GetPropertyAttributeWithFailedAccessCheck(
550 object, &r, name, continue_search); 551 object, &r, name, continue_search);
551 } 552 }
552 break; 553 break;
553 } 554 }
554 555
555 case INTERCEPTOR: { 556 case INTERCEPTOR: {
556 // If the object has an interceptor, try real named properties. 557 // If the object has an interceptor, try real named properties.
557 // No access check in GetPropertyAttributeWithInterceptor. 558 // No access check in GetPropertyAttributeWithInterceptor.
558 LookupResult r(object->GetIsolate()); 559 LookupResult r(object->GetIsolate());
559 if (continue_search) { 560 if (continue_search) {
560 result->holder()->LookupRealNamedProperty(*name, &r); 561 result->holder()->LookupRealNamedProperty(name, &r);
561 } else { 562 } else {
562 result->holder()->LocalLookupRealNamedProperty(*name, &r); 563 result->holder()->LocalLookupRealNamedProperty(name, &r);
563 } 564 }
564 if (!r.IsFound()) break; 565 if (!r.IsFound()) break;
565 return GetPropertyAttributeWithFailedAccessCheck( 566 return GetPropertyAttributeWithFailedAccessCheck(
566 object, &r, name, continue_search); 567 object, &r, name, continue_search);
567 } 568 }
568 569
569 case HANDLER: 570 case HANDLER:
570 case NONEXISTENT: 571 case NONEXISTENT:
571 UNREACHABLE(); 572 UNREACHABLE();
572 } 573 }
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 1991
1991 MaybeHandle<Object> JSObject::SetPropertyPostInterceptor( 1992 MaybeHandle<Object> JSObject::SetPropertyPostInterceptor(
1992 Handle<JSObject> object, 1993 Handle<JSObject> object,
1993 Handle<Name> name, 1994 Handle<Name> name,
1994 Handle<Object> value, 1995 Handle<Object> value,
1995 PropertyAttributes attributes, 1996 PropertyAttributes attributes,
1996 StrictMode strict_mode) { 1997 StrictMode strict_mode) {
1997 // Check local property, ignore interceptor. 1998 // Check local property, ignore interceptor.
1998 Isolate* isolate = object->GetIsolate(); 1999 Isolate* isolate = object->GetIsolate();
1999 LookupResult result(isolate); 2000 LookupResult result(isolate);
2000 object->LocalLookupRealNamedProperty(*name, &result); 2001 object->LocalLookupRealNamedProperty(name, &result);
2001 if (!result.IsFound()) { 2002 if (!result.IsFound()) {
2002 object->map()->LookupTransition(*object, *name, &result); 2003 object->map()->LookupTransition(*object, *name, &result);
2003 } 2004 }
2004 if (result.IsFound()) { 2005 if (result.IsFound()) {
2005 // 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
2006 // handle all these cases. 2007 // handle all these cases.
2007 return SetPropertyForResult(object, &result, name, value, attributes, 2008 return SetPropertyForResult(object, &result, name, value, attributes,
2008 strict_mode, MAY_BE_STORE_FROM_KEYED); 2009 strict_mode, MAY_BE_STORE_FROM_KEYED);
2009 } 2010 }
2010 bool done = false; 2011 bool done = false;
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 } 2970 }
2970 2971
2971 2972
2972 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, 2973 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
2973 Handle<Name> name, 2974 Handle<Name> name,
2974 Handle<Object> value, 2975 Handle<Object> value,
2975 PropertyAttributes attributes, 2976 PropertyAttributes attributes,
2976 StrictMode strict_mode, 2977 StrictMode strict_mode,
2977 StoreFromKeyed store_mode) { 2978 StoreFromKeyed store_mode) {
2978 LookupResult result(object->GetIsolate()); 2979 LookupResult result(object->GetIsolate());
2979 object->LocalLookup(*name, &result, true); 2980 object->LocalLookup(name, &result, true);
2980 if (!result.IsFound()) { 2981 if (!result.IsFound()) {
2981 object->map()->LookupTransition(JSObject::cast(*object), *name, &result); 2982 object->map()->LookupTransition(JSObject::cast(*object), *name, &result);
2982 } 2983 }
2983 return SetProperty(object, &result, name, value, attributes, strict_mode, 2984 return SetProperty(object, &result, name, value, attributes, strict_mode,
2984 store_mode); 2985 store_mode);
2985 } 2986 }
2986 2987
2987 2988
2988 MaybeHandle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object, 2989 MaybeHandle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object,
2989 Handle<Object> structure, 2990 Handle<Object> structure,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3121 PropertyAttributes attributes, 3122 PropertyAttributes attributes,
3122 StrictMode strict_mode, 3123 StrictMode strict_mode,
3123 bool* done) { 3124 bool* done) {
3124 Isolate* isolate = object->GetIsolate(); 3125 Isolate* isolate = object->GetIsolate();
3125 3126
3126 *done = false; 3127 *done = false;
3127 // We could not find a local property so let's check whether there is an 3128 // We could not find a local property so let's check whether there is an
3128 // 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
3129 // read-only on the prototype chain. 3130 // read-only on the prototype chain.
3130 LookupResult result(isolate); 3131 LookupResult result(isolate);
3131 object->LookupRealNamedPropertyInPrototypes(*name, &result); 3132 object->LookupRealNamedPropertyInPrototypes(name, &result);
3132 if (result.IsFound()) { 3133 if (result.IsFound()) {
3133 switch (result.type()) { 3134 switch (result.type()) {
3134 case NORMAL: 3135 case NORMAL:
3135 case FIELD: 3136 case FIELD:
3136 case CONSTANT: 3137 case CONSTANT:
3137 *done = result.IsReadOnly(); 3138 *done = result.IsReadOnly();
3138 break; 3139 break;
3139 case INTERCEPTOR: { 3140 case INTERCEPTOR: {
3140 PropertyAttributes attr = GetPropertyAttributeWithInterceptor( 3141 PropertyAttributes attr = GetPropertyAttributeWithInterceptor(
3141 handle(result.holder()), object, name, true); 3142 handle(result.holder()), object, name, true);
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 Handle<Map> closest_map(FindClosestElementsTransition(*map, kind)); 3486 Handle<Map> closest_map(FindClosestElementsTransition(*map, kind));
3486 3487
3487 if (closest_map->elements_kind() == kind) { 3488 if (closest_map->elements_kind() == kind) {
3488 return closest_map; 3489 return closest_map;
3489 } 3490 }
3490 3491
3491 return AddMissingElementsTransitions(closest_map, kind); 3492 return AddMissingElementsTransitions(closest_map, kind);
3492 } 3493 }
3493 3494
3494 3495
3495 void JSObject::LocalLookupRealNamedProperty(Name* name, LookupResult* result) { 3496 void JSObject::LocalLookupRealNamedProperty(Handle<Name> name,
3497 LookupResult* result) {
3496 DisallowHeapAllocation no_gc; 3498 DisallowHeapAllocation no_gc;
3497 if (IsJSGlobalProxy()) { 3499 if (IsJSGlobalProxy()) {
3498 Object* proto = GetPrototype(); 3500 Object* proto = GetPrototype();
3499 if (proto->IsNull()) return result->NotFound(); 3501 if (proto->IsNull()) return result->NotFound();
3500 ASSERT(proto->IsJSGlobalObject()); 3502 ASSERT(proto->IsJSGlobalObject());
3501 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); 3503 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result);
3502 } 3504 }
3503 3505
3504 if (HasFastProperties()) { 3506 if (HasFastProperties()) {
3505 map()->LookupDescriptor(this, name, result); 3507 map()->LookupDescriptor(this, *name, result);
3506 // A property or a map transition was found. We return all of these result 3508 // A property or a map transition was found. We return all of these result
3507 // types because LocalLookupRealNamedProperty is used when setting 3509 // types because LocalLookupRealNamedProperty is used when setting
3508 // properties where map transitions are handled. 3510 // properties where map transitions are handled.
3509 ASSERT(!result->IsFound() || 3511 ASSERT(!result->IsFound() ||
3510 (result->holder() == this && result->IsFastPropertyType())); 3512 (result->holder() == this && result->IsFastPropertyType()));
3511 // Disallow caching for uninitialized constants. These can only 3513 // Disallow caching for uninitialized constants. These can only
3512 // occur as fields. 3514 // occur as fields.
3513 if (result->IsField() && 3515 if (result->IsField() &&
3514 result->IsReadOnly() && 3516 result->IsReadOnly() &&
3515 RawFastPropertyAt(result->GetFieldIndex().field_index())->IsTheHole()) { 3517 RawFastPropertyAt(result->GetFieldIndex().field_index())->IsTheHole()) {
(...skipping 17 matching lines...) Expand all
3533 // found in the dictionary-mode objects. 3535 // found in the dictionary-mode objects.
3534 if (value->IsTheHole()) result->DisallowCaching(); 3536 if (value->IsTheHole()) result->DisallowCaching();
3535 result->DictionaryResult(this, entry); 3537 result->DictionaryResult(this, entry);
3536 return; 3538 return;
3537 } 3539 }
3538 3540
3539 result->NotFound(); 3541 result->NotFound();
3540 } 3542 }
3541 3543
3542 3544
3543 void JSObject::LookupRealNamedProperty(Name* name, LookupResult* result) { 3545 void JSObject::LookupRealNamedProperty(Handle<Name> name,
3546 LookupResult* result) {
3547 DisallowHeapAllocation no_gc;
3544 LocalLookupRealNamedProperty(name, result); 3548 LocalLookupRealNamedProperty(name, result);
3545 if (result->IsFound()) return; 3549 if (result->IsFound()) return;
3546 3550
3547 LookupRealNamedPropertyInPrototypes(name, result); 3551 LookupRealNamedPropertyInPrototypes(name, result);
3548 } 3552 }
3549 3553
3550 3554
3551 void JSObject::LookupRealNamedPropertyInPrototypes(Name* name, 3555 void JSObject::LookupRealNamedPropertyInPrototypes(Handle<Name> name,
3552 LookupResult* result) { 3556 LookupResult* result) {
3557 DisallowHeapAllocation no_gc;
3553 Isolate* isolate = GetIsolate(); 3558 Isolate* isolate = GetIsolate();
3554 Heap* heap = isolate->heap(); 3559 Heap* heap = isolate->heap();
3555 for (Object* pt = GetPrototype(); 3560 for (Object* pt = GetPrototype();
3556 pt != heap->null_value(); 3561 pt != heap->null_value();
3557 pt = pt->GetPrototype(isolate)) { 3562 pt = pt->GetPrototype(isolate)) {
3558 if (pt->IsJSProxy()) { 3563 if (pt->IsJSProxy()) {
3559 return result->HandlerResult(JSProxy::cast(pt)); 3564 return result->HandlerResult(JSProxy::cast(pt));
3560 } 3565 }
3561 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); 3566 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
3562 ASSERT(!(result->IsFound() && result->type() == INTERCEPTOR)); 3567 ASSERT(!(result->IsFound() && result->type() == INTERCEPTOR));
3563 if (result->IsFound()) return; 3568 if (result->IsFound()) return;
3564 } 3569 }
3565 result->NotFound(); 3570 result->NotFound();
3566 } 3571 }
3567 3572
3568 3573
3569 // We only need to deal with CALLBACKS and INTERCEPTORS 3574 // We only need to deal with CALLBACKS and INTERCEPTORS
3570 MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck( 3575 MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck(
3571 Handle<JSObject> object, 3576 Handle<JSObject> object,
3572 LookupResult* result, 3577 LookupResult* result,
3573 Handle<Name> name, 3578 Handle<Name> name,
3574 Handle<Object> value, 3579 Handle<Object> value,
3575 bool check_prototype, 3580 bool check_prototype,
3576 StrictMode strict_mode) { 3581 StrictMode strict_mode) {
3577 if (check_prototype && !result->IsProperty()) { 3582 if (check_prototype && !result->IsProperty()) {
3578 object->LookupRealNamedPropertyInPrototypes(*name, result); 3583 object->LookupRealNamedPropertyInPrototypes(name, result);
3579 } 3584 }
3580 3585
3581 if (result->IsProperty()) { 3586 if (result->IsProperty()) {
3582 if (!result->IsReadOnly()) { 3587 if (!result->IsReadOnly()) {
3583 switch (result->type()) { 3588 switch (result->type()) {
3584 case CALLBACKS: { 3589 case CALLBACKS: {
3585 Object* obj = result->GetCallbackObject(); 3590 Object* obj = result->GetCallbackObject();
3586 if (obj->IsAccessorInfo()) { 3591 if (obj->IsAccessorInfo()) {
3587 Handle<AccessorInfo> info(AccessorInfo::cast(obj)); 3592 Handle<AccessorInfo> info(AccessorInfo::cast(obj));
3588 if (info->all_can_write()) { 3593 if (info->all_can_write()) {
(...skipping 14 matching lines...) Expand all
3603 handle(result->holder()), 3608 handle(result->holder()),
3604 strict_mode); 3609 strict_mode);
3605 } 3610 }
3606 } 3611 }
3607 break; 3612 break;
3608 } 3613 }
3609 case INTERCEPTOR: { 3614 case INTERCEPTOR: {
3610 // Try lookup real named properties. Note that only property can be 3615 // Try lookup real named properties. Note that only property can be
3611 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain. 3616 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain.
3612 LookupResult r(object->GetIsolate()); 3617 LookupResult r(object->GetIsolate());
3613 object->LookupRealNamedProperty(*name, &r); 3618 object->LookupRealNamedProperty(name, &r);
3614 if (r.IsProperty()) { 3619 if (r.IsProperty()) {
3615 return SetPropertyWithFailedAccessCheck(object, 3620 return SetPropertyWithFailedAccessCheck(object,
3616 &r, 3621 &r,
3617 name, 3622 name,
3618 value, 3623 value,
3619 check_prototype, 3624 check_prototype,
3620 strict_mode); 3625 strict_mode);
3621 } 3626 }
3622 break; 3627 break;
3623 } 3628 }
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
4275 } 4280 }
4276 4281
4277 Handle<Object> result; 4282 Handle<Object> result;
4278 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); 4283 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
4279 4284
4280 if (is_observed) { 4285 if (is_observed) {
4281 if (lookup->IsTransition()) { 4286 if (lookup->IsTransition()) {
4282 EnqueueChangeRecord(object, "add", name, old_value); 4287 EnqueueChangeRecord(object, "add", name, old_value);
4283 } else { 4288 } else {
4284 LookupResult new_lookup(isolate); 4289 LookupResult new_lookup(isolate);
4285 object->LocalLookup(*name, &new_lookup, true); 4290 object->LocalLookup(name, &new_lookup, true);
4286 if (new_lookup.IsDataProperty()) { 4291 if (new_lookup.IsDataProperty()) {
4287 Handle<Object> new_value = 4292 Handle<Object> new_value =
4288 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 4293 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4289 if (!new_value->SameValue(*old_value)) { 4294 if (!new_value->SameValue(*old_value)) {
4290 EnqueueChangeRecord(object, "update", name, old_value); 4295 EnqueueChangeRecord(object, "update", name, old_value);
4291 } 4296 }
4292 } 4297 }
4293 } 4298 }
4294 } 4299 }
4295 4300
(...skipping 18 matching lines...) Expand all
4314 ValueType value_type, 4319 ValueType value_type,
4315 StoreMode mode, 4320 StoreMode mode,
4316 ExtensibilityCheck extensibility_check) { 4321 ExtensibilityCheck extensibility_check) {
4317 Isolate* isolate = object->GetIsolate(); 4322 Isolate* isolate = object->GetIsolate();
4318 4323
4319 // Make sure that the top context does not change when doing callbacks or 4324 // Make sure that the top context does not change when doing callbacks or
4320 // interceptor calls. 4325 // interceptor calls.
4321 AssertNoContextChange ncc(isolate); 4326 AssertNoContextChange ncc(isolate);
4322 4327
4323 LookupResult lookup(isolate); 4328 LookupResult lookup(isolate);
4324 object->LocalLookup(*name, &lookup, true); 4329 object->LocalLookup(name, &lookup, true);
4325 if (!lookup.IsFound()) { 4330 if (!lookup.IsFound()) {
4326 object->map()->LookupTransition(*object, *name, &lookup); 4331 object->map()->LookupTransition(*object, *name, &lookup);
4327 } 4332 }
4328 4333
4329 // Check access rights if needed. 4334 // Check access rights if needed.
4330 if (object->IsAccessCheckNeeded()) { 4335 if (object->IsAccessCheckNeeded()) {
4331 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { 4336 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) {
4332 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, 4337 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value,
4333 false, SLOPPY); 4338 false, SLOPPY);
4334 } 4339 }
4335 } 4340 }
4336 4341
4337 if (object->IsJSGlobalProxy()) { 4342 if (object->IsJSGlobalProxy()) {
4338 Handle<Object> proto(object->GetPrototype(), isolate); 4343 Handle<Object> proto(object->GetPrototype(), isolate);
4339 if (proto->IsNull()) return value; 4344 if (proto->IsNull()) return value;
4340 ASSERT(proto->IsJSGlobalObject()); 4345 ASSERT(proto->IsJSGlobalObject());
4341 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), 4346 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto),
4342 name, value, attributes, value_type, mode, extensibility_check); 4347 name, value, attributes, value_type, mode, extensibility_check);
4343 } 4348 }
4344 4349
4345 if (lookup.IsInterceptor() || 4350 if (lookup.IsInterceptor() ||
4346 (lookup.IsDescriptorOrDictionary() && lookup.type() == CALLBACKS)) { 4351 (lookup.IsDescriptorOrDictionary() && lookup.type() == CALLBACKS)) {
4347 object->LocalLookupRealNamedProperty(*name, &lookup); 4352 object->LocalLookupRealNamedProperty(name, &lookup);
4348 } 4353 }
4349 4354
4350 // Check for accessor in prototype chain removed here in clone. 4355 // Check for accessor in prototype chain removed here in clone.
4351 if (!lookup.IsFound()) { 4356 if (!lookup.IsFound()) {
4352 object->map()->LookupTransition(*object, *name, &lookup); 4357 object->map()->LookupTransition(*object, *name, &lookup);
4353 TransitionFlag flag = lookup.IsFound() 4358 TransitionFlag flag = lookup.IsFound()
4354 ? OMIT_TRANSITION : INSERT_TRANSITION; 4359 ? OMIT_TRANSITION : INSERT_TRANSITION;
4355 // Neither properties nor transitions found. 4360 // Neither properties nor transitions found.
4356 return AddProperty(object, name, value, attributes, SLOPPY, 4361 return AddProperty(object, name, value, attributes, SLOPPY,
4357 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode, flag); 4362 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode, flag);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 } 4406 }
4402 } 4407 }
4403 4408
4404 if (is_observed) { 4409 if (is_observed) {
4405 if (lookup.IsTransition()) { 4410 if (lookup.IsTransition()) {
4406 EnqueueChangeRecord(object, "add", name, old_value); 4411 EnqueueChangeRecord(object, "add", name, old_value);
4407 } else if (old_value->IsTheHole()) { 4412 } else if (old_value->IsTheHole()) {
4408 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4413 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4409 } else { 4414 } else {
4410 LookupResult new_lookup(isolate); 4415 LookupResult new_lookup(isolate);
4411 object->LocalLookup(*name, &new_lookup, true); 4416 object->LocalLookup(name, &new_lookup, true);
4412 bool value_changed = false; 4417 bool value_changed = false;
4413 if (new_lookup.IsDataProperty()) { 4418 if (new_lookup.IsDataProperty()) {
4414 Handle<Object> new_value = 4419 Handle<Object> new_value =
4415 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 4420 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4416 value_changed = !old_value->SameValue(*new_value); 4421 value_changed = !old_value->SameValue(*new_value);
4417 } 4422 }
4418 if (new_lookup.GetAttributes() != old_attributes) { 4423 if (new_lookup.GetAttributes() != old_attributes) {
4419 if (!value_changed) old_value = isolate->factory()->the_hole_value(); 4424 if (!value_changed) old_value = isolate->factory()->the_hole_value();
4420 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4425 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4421 } else if (value_changed) { 4426 } else if (value_changed) {
4422 EnqueueChangeRecord(object, "update", name, old_value); 4427 EnqueueChangeRecord(object, "update", name, old_value);
4423 } 4428 }
4424 } 4429 }
4425 } 4430 }
4426 4431
4427 return value; 4432 return value;
4428 } 4433 }
4429 4434
4430 4435
4431 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( 4436 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor(
4432 Handle<JSObject> object, 4437 Handle<JSObject> object,
4433 Handle<JSObject> receiver, 4438 Handle<JSObject> receiver,
4434 Handle<Name> name, 4439 Handle<Name> name,
4435 bool continue_search) { 4440 bool continue_search) {
4436 // Check local property, ignore interceptor. 4441 // Check local property, ignore interceptor.
4437 Isolate* isolate = object->GetIsolate(); 4442 Isolate* isolate = object->GetIsolate();
4438 LookupResult result(isolate); 4443 LookupResult result(isolate);
4439 object->LocalLookupRealNamedProperty(*name, &result); 4444 object->LocalLookupRealNamedProperty(name, &result);
4440 if (result.IsFound()) return result.GetAttributes(); 4445 if (result.IsFound()) return result.GetAttributes();
4441 4446
4442 if (continue_search) { 4447 if (continue_search) {
4443 // Continue searching via the prototype chain. 4448 // Continue searching via the prototype chain.
4444 Handle<Object> proto(object->GetPrototype(), isolate); 4449 Handle<Object> proto(object->GetPrototype(), isolate);
4445 if (!proto->IsNull()) { 4450 if (!proto->IsNull()) {
4446 return JSReceiver::GetPropertyAttributeWithReceiver( 4451 return JSReceiver::GetPropertyAttributeWithReceiver(
4447 Handle<JSObject>::cast(proto), receiver, name); 4452 Handle<JSObject>::cast(proto), receiver, name);
4448 } 4453 }
4449 } 4454 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4498 Handle<JSReceiver> object, 4503 Handle<JSReceiver> object,
4499 Handle<JSReceiver> receiver, 4504 Handle<JSReceiver> receiver,
4500 Handle<Name> key) { 4505 Handle<Name> key) {
4501 uint32_t index = 0; 4506 uint32_t index = 0;
4502 if (object->IsJSObject() && key->AsArrayIndex(&index)) { 4507 if (object->IsJSObject() && key->AsArrayIndex(&index)) {
4503 return JSObject::GetElementAttributeWithReceiver( 4508 return JSObject::GetElementAttributeWithReceiver(
4504 Handle<JSObject>::cast(object), receiver, index, true); 4509 Handle<JSObject>::cast(object), receiver, index, true);
4505 } 4510 }
4506 // Named property. 4511 // Named property.
4507 LookupResult lookup(object->GetIsolate()); 4512 LookupResult lookup(object->GetIsolate());
4508 object->Lookup(*key, &lookup); 4513 object->Lookup(key, &lookup);
4509 return GetPropertyAttributeForResult(object, receiver, &lookup, key, true); 4514 return GetPropertyAttributeForResult(object, receiver, &lookup, key, true);
4510 } 4515 }
4511 4516
4512 4517
4513 PropertyAttributes JSReceiver::GetPropertyAttributeForResult( 4518 PropertyAttributes JSReceiver::GetPropertyAttributeForResult(
4514 Handle<JSReceiver> object, 4519 Handle<JSReceiver> object,
4515 Handle<JSReceiver> receiver, 4520 Handle<JSReceiver> receiver,
4516 LookupResult* lookup, 4521 LookupResult* lookup,
4517 Handle<Name> name, 4522 Handle<Name> name,
4518 bool continue_search) { 4523 bool continue_search) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 4557
4553 PropertyAttributes JSReceiver::GetLocalPropertyAttribute( 4558 PropertyAttributes JSReceiver::GetLocalPropertyAttribute(
4554 Handle<JSReceiver> object, Handle<Name> name) { 4559 Handle<JSReceiver> object, Handle<Name> name) {
4555 // Check whether the name is an array index. 4560 // Check whether the name is an array index.
4556 uint32_t index = 0; 4561 uint32_t index = 0;
4557 if (object->IsJSObject() && name->AsArrayIndex(&index)) { 4562 if (object->IsJSObject() && name->AsArrayIndex(&index)) {
4558 return GetLocalElementAttribute(object, index); 4563 return GetLocalElementAttribute(object, index);
4559 } 4564 }
4560 // Named property. 4565 // Named property.
4561 LookupResult lookup(object->GetIsolate()); 4566 LookupResult lookup(object->GetIsolate());
4562 object->LocalLookup(*name, &lookup, true); 4567 object->LocalLookup(name, &lookup, true);
4563 return GetPropertyAttributeForResult(object, object, &lookup, name, false); 4568 return GetPropertyAttributeForResult(object, object, &lookup, name, false);
4564 } 4569 }
4565 4570
4566 4571
4567 PropertyAttributes JSObject::GetElementAttributeWithReceiver( 4572 PropertyAttributes JSObject::GetElementAttributeWithReceiver(
4568 Handle<JSObject> object, 4573 Handle<JSObject> object,
4569 Handle<JSReceiver> receiver, 4574 Handle<JSReceiver> receiver,
4570 uint32_t index, 4575 uint32_t index,
4571 bool continue_search) { 4576 bool continue_search) {
4572 Isolate* isolate = object->GetIsolate(); 4577 Isolate* isolate = object->GetIsolate();
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 IsCompatibleForLoad(Representation::Tagged())); 5274 IsCompatibleForLoad(Representation::Tagged()));
5270 return this->RawFastPropertyAt( 5275 return this->RawFastPropertyAt(
5271 descriptors->GetFieldIndex(sorted_index)); 5276 descriptors->GetFieldIndex(sorted_index));
5272 } else { 5277 } else {
5273 return GetHeap()->undefined_value(); 5278 return GetHeap()->undefined_value();
5274 } 5279 }
5275 } else { 5280 } else {
5276 return GetHeap()->undefined_value(); 5281 return GetHeap()->undefined_value();
5277 } 5282 }
5278 } else { 5283 } else {
5279 LookupResult result(GetIsolate()); 5284 Isolate* isolate = GetIsolate();
5280 LocalLookupRealNamedProperty(GetHeap()->hidden_string(), &result); 5285 LookupResult result(isolate);
5286 LocalLookupRealNamedProperty(isolate->factory()->hidden_string(), &result);
5281 if (result.IsFound()) { 5287 if (result.IsFound()) {
5282 ASSERT(result.IsNormal()); 5288 ASSERT(result.IsNormal());
5283 ASSERT(result.holder() == this); 5289 ASSERT(result.holder() == this);
5284 Object* value = GetNormalizedProperty(&result); 5290 Object* value = GetNormalizedProperty(&result);
5285 if (!value->IsTheHole()) return value; 5291 if (!value->IsTheHole()) return value;
5286 } 5292 }
5287 return GetHeap()->undefined_value(); 5293 return GetHeap()->undefined_value();
5288 } 5294 }
5289 } 5295 }
5290 5296
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5357 return object; 5363 return object;
5358 } 5364 }
5359 5365
5360 5366
5361 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object, 5367 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object,
5362 Handle<Name> name, 5368 Handle<Name> name,
5363 DeleteMode mode) { 5369 DeleteMode mode) {
5364 // Check local property, ignore interceptor. 5370 // Check local property, ignore interceptor.
5365 Isolate* isolate = object->GetIsolate(); 5371 Isolate* isolate = object->GetIsolate();
5366 LookupResult result(isolate); 5372 LookupResult result(isolate);
5367 object->LocalLookupRealNamedProperty(*name, &result); 5373 object->LocalLookupRealNamedProperty(name, &result);
5368 if (!result.IsFound()) return isolate->factory()->true_value(); 5374 if (!result.IsFound()) return isolate->factory()->true_value();
5369 5375
5370 // Normalize object if needed. 5376 // Normalize object if needed.
5371 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); 5377 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
5372 5378
5373 return DeleteNormalizedProperty(object, name, mode); 5379 return DeleteNormalizedProperty(object, name, mode);
5374 } 5380 }
5375 5381
5376 5382
5377 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor( 5383 MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor(
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5529 return JSGlobalObject::DeleteProperty( 5535 return JSGlobalObject::DeleteProperty(
5530 handle(JSGlobalObject::cast(proto)), name, mode); 5536 handle(JSGlobalObject::cast(proto)), name, mode);
5531 } 5537 }
5532 5538
5533 uint32_t index = 0; 5539 uint32_t index = 0;
5534 if (name->AsArrayIndex(&index)) { 5540 if (name->AsArrayIndex(&index)) {
5535 return DeleteElement(object, index, mode); 5541 return DeleteElement(object, index, mode);
5536 } 5542 }
5537 5543
5538 LookupResult lookup(isolate); 5544 LookupResult lookup(isolate);
5539 object->LocalLookup(*name, &lookup, true); 5545 object->LocalLookup(name, &lookup, true);
5540 if (!lookup.IsFound()) return isolate->factory()->true_value(); 5546 if (!lookup.IsFound()) return isolate->factory()->true_value();
5541 // Ignore attributes if forcing a deletion. 5547 // Ignore attributes if forcing a deletion.
5542 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { 5548 if (lookup.IsDontDelete() && mode != FORCE_DELETION) {
5543 if (mode == STRICT_DELETION) { 5549 if (mode == STRICT_DELETION) {
5544 // Deleting a non-configurable property in strict mode. 5550 // Deleting a non-configurable property in strict mode.
5545 Handle<Object> args[2] = { name, object }; 5551 Handle<Object> args[2] = { name, object };
5546 Handle<Object> error = isolate->factory()->NewTypeError( 5552 Handle<Object> error = isolate->factory()->NewTypeError(
5547 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args))); 5553 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args)));
5548 isolate->Throw(*error); 5554 isolate->Throw(*error);
5549 return Handle<Object>(); 5555 return Handle<Object>();
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
6184 return copy; 6190 return copy;
6185 } 6191 }
6186 6192
6187 6193
6188 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object, 6194 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
6189 Handle<Name> key) { 6195 Handle<Name> key) {
6190 Isolate* isolate = object->GetIsolate(); 6196 Isolate* isolate = object->GetIsolate();
6191 LookupResult lookup(isolate); 6197 LookupResult lookup(isolate);
6192 { 6198 {
6193 DisallowHeapAllocation no_allocation; 6199 DisallowHeapAllocation no_allocation;
6194 object->LookupRealNamedProperty(*key, &lookup); 6200 object->LookupRealNamedProperty(key, &lookup);
6195 } 6201 }
6196 Handle<Object> result = isolate->factory()->undefined_value(); 6202 Handle<Object> result = isolate->factory()->undefined_value();
6197 if (lookup.IsFound() && !lookup.IsTransition()) { 6203 if (lookup.IsFound() && !lookup.IsTransition()) {
6198 switch (lookup.type()) { 6204 switch (lookup.type()) {
6199 case NORMAL: 6205 case NORMAL:
6200 result = GetNormalizedProperty( 6206 result = GetNormalizedProperty(
6201 Handle<JSObject>(lookup.holder(), isolate), &lookup); 6207 Handle<JSObject>(lookup.holder(), isolate), &lookup);
6202 break; 6208 break;
6203 case FIELD: 6209 case FIELD:
6204 result = FastPropertyAt(Handle<JSObject>(lookup.holder(), isolate), 6210 result = FastPropertyAt(Handle<JSObject>(lookup.holder(), isolate),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
6287 if (descs->GetType(i) == FIELD) { 6293 if (descs->GetType(i) == FIELD) {
6288 int current_index = descs->GetFieldIndex(i); 6294 int current_index = descs->GetFieldIndex(i);
6289 if (current_index > max_index) max_index = current_index; 6295 if (current_index > max_index) max_index = current_index;
6290 } 6296 }
6291 } 6297 }
6292 return max_index + 1; 6298 return max_index + 1;
6293 } 6299 }
6294 6300
6295 6301
6296 void JSReceiver::LocalLookup( 6302 void JSReceiver::LocalLookup(
6297 Name* name, LookupResult* result, bool search_hidden_prototypes) { 6303 Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) {
6304 DisallowHeapAllocation no_gc;
6298 ASSERT(name->IsName()); 6305 ASSERT(name->IsName());
6299 6306
6300 Heap* heap = GetHeap();
6301
6302 if (IsJSGlobalProxy()) { 6307 if (IsJSGlobalProxy()) {
6303 Object* proto = GetPrototype(); 6308 Object* proto = GetPrototype();
6304 if (proto->IsNull()) return result->NotFound(); 6309 if (proto->IsNull()) return result->NotFound();
6305 ASSERT(proto->IsJSGlobalObject()); 6310 ASSERT(proto->IsJSGlobalObject());
6306 return JSReceiver::cast(proto)->LocalLookup( 6311 return JSReceiver::cast(proto)->LocalLookup(
6307 name, result, search_hidden_prototypes); 6312 name, result, search_hidden_prototypes);
6308 } 6313 }
6309 6314
6310 if (IsJSProxy()) { 6315 if (IsJSProxy()) {
6311 result->HandlerResult(JSProxy::cast(this)); 6316 result->HandlerResult(JSProxy::cast(this));
6312 return; 6317 return;
6313 } 6318 }
6314 6319
6315 // Do not use inline caching if the object is a non-global object 6320 // Do not use inline caching if the object is a non-global object
6316 // that requires access checks. 6321 // that requires access checks.
6317 if (IsAccessCheckNeeded()) { 6322 if (IsAccessCheckNeeded()) {
6318 result->DisallowCaching(); 6323 result->DisallowCaching();
6319 } 6324 }
6320 6325
6321 JSObject* js_object = JSObject::cast(this); 6326 JSObject* js_object = JSObject::cast(this);
6322 6327
6323 // Check for lookup interceptor except when bootstrapping. 6328 // Check for lookup interceptor except when bootstrapping.
6324 if (js_object->HasNamedInterceptor() && 6329 if (js_object->HasNamedInterceptor() &&
6325 !heap->isolate()->bootstrapper()->IsActive()) { 6330 !GetIsolate()->bootstrapper()->IsActive()) {
6326 result->InterceptorResult(js_object); 6331 result->InterceptorResult(js_object);
6327 return; 6332 return;
6328 } 6333 }
6329 6334
6330 js_object->LocalLookupRealNamedProperty(name, result); 6335 js_object->LocalLookupRealNamedProperty(name, result);
6331 if (result->IsFound() || !search_hidden_prototypes) return; 6336 if (result->IsFound() || !search_hidden_prototypes) return;
6332 6337
6333 Object* proto = js_object->GetPrototype(); 6338 Object* proto = js_object->GetPrototype();
6334 if (!proto->IsJSReceiver()) return; 6339 if (!proto->IsJSReceiver()) return;
6335 JSReceiver* receiver = JSReceiver::cast(proto); 6340 JSReceiver* receiver = JSReceiver::cast(proto);
6336 if (receiver->map()->is_hidden_prototype()) { 6341 if (receiver->map()->is_hidden_prototype()) {
6337 receiver->LocalLookup(name, result, search_hidden_prototypes); 6342 receiver->LocalLookup(name, result, search_hidden_prototypes);
6338 } 6343 }
6339 } 6344 }
6340 6345
6341 6346
6342 void JSReceiver::Lookup(Name* name, LookupResult* result) { 6347 void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) {
6348 DisallowHeapAllocation no_gc;
6343 // Ecma-262 3rd 8.6.2.4 6349 // Ecma-262 3rd 8.6.2.4
6344 Heap* heap = GetHeap(); 6350 Handle<Object> null_value = GetIsolate()->factory()->null_value();
6345 for (Object* current = this; 6351 for (Object* current = this;
6346 current != heap->null_value(); 6352 current != *null_value;
6347 current = JSObject::cast(current)->GetPrototype()) { 6353 current = JSObject::cast(current)->GetPrototype()) {
6348 JSReceiver::cast(current)->LocalLookup(name, result, false); 6354 JSReceiver::cast(current)->LocalLookup(name, result, false);
6349 if (result->IsFound()) return; 6355 if (result->IsFound()) return;
6350 } 6356 }
6351 result->NotFound(); 6357 result->NotFound();
6352 } 6358 }
6353 6359
6354 6360
6355 // Search object and its prototype chain for callback properties. 6361 // Search object and its prototype chain for callback properties.
6356 void JSObject::LookupCallbackProperty(Name* name, LookupResult* result) { 6362 void JSObject::LookupCallbackProperty(Handle<Name> name, LookupResult* result) {
6357 Heap* heap = GetHeap(); 6363 DisallowHeapAllocation no_gc;
6364 Handle<Object> null_value = GetIsolate()->factory()->null_value();
6358 for (Object* current = this; 6365 for (Object* current = this;
6359 current != heap->null_value() && current->IsJSObject(); 6366 current != *null_value && current->IsJSObject();
6360 current = JSObject::cast(current)->GetPrototype()) { 6367 current = JSObject::cast(current)->GetPrototype()) {
6361 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); 6368 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
6362 if (result->IsPropertyCallbacks()) return; 6369 if (result->IsPropertyCallbacks()) return;
6363 } 6370 }
6364 result->NotFound(); 6371 result->NotFound();
6365 } 6372 }
6366 6373
6367 6374
6368 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { 6375 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
6369 int len = array->length(); 6376 int len = array->length();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
6698 accessors->set_access_flags(access_control); 6705 accessors->set_access_flags(access_control);
6699 6706
6700 SetElementCallback(object, index, accessors, attributes); 6707 SetElementCallback(object, index, accessors, attributes);
6701 } 6708 }
6702 6709
6703 6710
6704 Handle<AccessorPair> JSObject::CreateAccessorPairFor(Handle<JSObject> object, 6711 Handle<AccessorPair> JSObject::CreateAccessorPairFor(Handle<JSObject> object,
6705 Handle<Name> name) { 6712 Handle<Name> name) {
6706 Isolate* isolate = object->GetIsolate(); 6713 Isolate* isolate = object->GetIsolate();
6707 LookupResult result(isolate); 6714 LookupResult result(isolate);
6708 object->LocalLookupRealNamedProperty(*name, &result); 6715 object->LocalLookupRealNamedProperty(name, &result);
6709 if (result.IsPropertyCallbacks()) { 6716 if (result.IsPropertyCallbacks()) {
6710 // Note that the result can actually have IsDontDelete() == true when we 6717 // Note that the result can actually have IsDontDelete() == true when we
6711 // e.g. have to fall back to the slow case while adding a setter after 6718 // e.g. have to fall back to the slow case while adding a setter after
6712 // successfully reusing a map transition for a getter. Nevertheless, this is 6719 // successfully reusing a map transition for a getter. Nevertheless, this is
6713 // OK, because the assertion only holds for the whole addition of both 6720 // OK, because the assertion only holds for the whole addition of both
6714 // accessors, not for the addition of each part. See first comment in 6721 // accessors, not for the addition of each part. See first comment in
6715 // DefinePropertyAccessor below. 6722 // DefinePropertyAccessor below.
6716 Object* obj = result.GetCallbackObject(); 6723 Object* obj = result.GetCallbackObject();
6717 if (obj->IsAccessorPair()) { 6724 if (obj->IsAccessorPair()) {
6718 return AccessorPair::Copy(handle(AccessorPair::cast(obj), isolate)); 6725 return AccessorPair::Copy(handle(AccessorPair::cast(obj), isolate));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6754 ASSERT(!object->IsAccessCheckNeeded() || 6761 ASSERT(!object->IsAccessCheckNeeded() ||
6755 isolate->MayNamedAccess(object, name, v8::ACCESS_SET)); 6762 isolate->MayNamedAccess(object, name, v8::ACCESS_SET));
6756 6763
6757 // Check if there is an API defined callback object which prohibits 6764 // Check if there is an API defined callback object which prohibits
6758 // callback overwriting in this object or its prototype chain. 6765 // callback overwriting in this object or its prototype chain.
6759 // This mechanism is needed for instance in a browser setting, where 6766 // This mechanism is needed for instance in a browser setting, where
6760 // certain accessors such as window.location should not be allowed 6767 // certain accessors such as window.location should not be allowed
6761 // to be overwritten because allowing overwriting could potentially 6768 // to be overwritten because allowing overwriting could potentially
6762 // cause security problems. 6769 // cause security problems.
6763 LookupResult callback_result(isolate); 6770 LookupResult callback_result(isolate);
6764 object->LookupCallbackProperty(*name, &callback_result); 6771 object->LookupCallbackProperty(name, &callback_result);
6765 if (callback_result.IsFound()) { 6772 if (callback_result.IsFound()) {
6766 Object* callback_obj = callback_result.GetCallbackObject(); 6773 Object* callback_obj = callback_result.GetCallbackObject();
6767 if (callback_obj->IsAccessorInfo()) { 6774 if (callback_obj->IsAccessorInfo()) {
6768 return !AccessorInfo::cast(callback_obj)->prohibits_overwriting(); 6775 return !AccessorInfo::cast(callback_obj)->prohibits_overwriting();
6769 } 6776 }
6770 if (callback_obj->IsAccessorPair()) { 6777 if (callback_obj->IsAccessorPair()) {
6771 return !AccessorPair::cast(callback_obj)->prohibits_overwriting(); 6778 return !AccessorPair::cast(callback_obj)->prohibits_overwriting();
6772 } 6779 }
6773 } 6780 }
6774 return true; 6781 return true;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6912 bool preexists = false; 6919 bool preexists = false;
6913 if (is_observed) { 6920 if (is_observed) {
6914 if (is_element) { 6921 if (is_element) {
6915 preexists = HasLocalElement(object, index); 6922 preexists = HasLocalElement(object, index);
6916 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) { 6923 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) {
6917 old_value = 6924 old_value =
6918 Object::GetElement(isolate, object, index).ToHandleChecked(); 6925 Object::GetElement(isolate, object, index).ToHandleChecked();
6919 } 6926 }
6920 } else { 6927 } else {
6921 LookupResult lookup(isolate); 6928 LookupResult lookup(isolate);
6922 object->LocalLookup(*name, &lookup, true); 6929 object->LocalLookup(name, &lookup, true);
6923 preexists = lookup.IsProperty(); 6930 preexists = lookup.IsProperty();
6924 if (preexists && lookup.IsDataProperty()) { 6931 if (preexists && lookup.IsDataProperty()) {
6925 old_value = 6932 old_value =
6926 Object::GetPropertyOrElement(object, name).ToHandleChecked(); 6933 Object::GetPropertyOrElement(object, name).ToHandleChecked();
6927 } 6934 }
6928 } 6935 }
6929 } 6936 }
6930 6937
6931 if (is_element) { 6938 if (is_element) {
6932 DefineElementAccessor( 6939 DefineElementAccessor(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6973 6980
6974 6981
6975 bool JSObject::DefineFastAccessor(Handle<JSObject> object, 6982 bool JSObject::DefineFastAccessor(Handle<JSObject> object,
6976 Handle<Name> name, 6983 Handle<Name> name,
6977 AccessorComponent component, 6984 AccessorComponent component,
6978 Handle<Object> accessor, 6985 Handle<Object> accessor,
6979 PropertyAttributes attributes) { 6986 PropertyAttributes attributes) {
6980 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined()); 6987 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined());
6981 Isolate* isolate = object->GetIsolate(); 6988 Isolate* isolate = object->GetIsolate();
6982 LookupResult result(isolate); 6989 LookupResult result(isolate);
6983 object->LocalLookup(*name, &result); 6990 object->LocalLookup(name, &result);
6984 6991
6985 if (result.IsFound() && !result.IsPropertyCallbacks()) { 6992 if (result.IsFound() && !result.IsPropertyCallbacks()) {
6986 return false; 6993 return false;
6987 } 6994 }
6988 6995
6989 // Return success if the same accessor with the same attributes already exist. 6996 // Return success if the same accessor with the same attributes already exist.
6990 AccessorPair* source_accessors = NULL; 6997 AccessorPair* source_accessors = NULL;
6991 if (result.IsPropertyCallbacks()) { 6998 if (result.IsPropertyCallbacks()) {
6992 Object* callback_value = result.GetCallbackObject(); 6999 Object* callback_value = result.GetCallbackObject();
6993 if (callback_value->IsAccessorPair()) { 7000 if (callback_value->IsAccessorPair()) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
7108 break; 7115 break;
7109 case SLOPPY_ARGUMENTS_ELEMENTS: 7116 case SLOPPY_ARGUMENTS_ELEMENTS:
7110 UNIMPLEMENTED(); 7117 UNIMPLEMENTED();
7111 break; 7118 break;
7112 } 7119 }
7113 7120
7114 SetElementCallback(object, index, info, info->property_attributes()); 7121 SetElementCallback(object, index, info, info->property_attributes());
7115 } else { 7122 } else {
7116 // Lookup the name. 7123 // Lookup the name.
7117 LookupResult result(isolate); 7124 LookupResult result(isolate);
7118 object->LocalLookup(*name, &result, true); 7125 object->LocalLookup(name, &result, true);
7119 // ES5 forbids turning a property into an accessor if it's not 7126 // ES5 forbids turning a property into an accessor if it's not
7120 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). 7127 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
7121 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) { 7128 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
7122 return factory->undefined_value(); 7129 return factory->undefined_value();
7123 } 7130 }
7124 7131
7125 SetPropertyCallback(object, name, info, info->property_attributes()); 7132 SetPropertyCallback(object, name, info, info->property_attributes());
7126 } 7133 }
7127 7134
7128 return object; 7135 return object;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7164 isolate); 7171 isolate);
7165 } 7172 }
7166 } 7173 }
7167 } 7174 }
7168 } 7175 }
7169 } else { 7176 } else {
7170 for (Handle<Object> obj = object; 7177 for (Handle<Object> obj = object;
7171 !obj->IsNull(); 7178 !obj->IsNull();
7172 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { 7179 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
7173 LookupResult result(isolate); 7180 LookupResult result(isolate);
7174 JSReceiver::cast(*obj)->LocalLookup(*name, &result); 7181 JSReceiver::cast(*obj)->LocalLookup(name, &result);
7175 if (result.IsFound()) { 7182 if (result.IsFound()) {
7176 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); 7183 if (result.IsReadOnly()) return isolate->factory()->undefined_value();
7177 if (result.IsPropertyCallbacks()) { 7184 if (result.IsPropertyCallbacks()) {
7178 Object* obj = result.GetCallbackObject(); 7185 Object* obj = result.GetCallbackObject();
7179 if (obj->IsAccessorPair()) { 7186 if (obj->IsAccessorPair()) {
7180 return handle(AccessorPair::cast(obj)->GetComponent(component), 7187 return handle(AccessorPair::cast(obj)->GetComponent(component),
7181 isolate); 7188 isolate);
7182 } 7189 }
7183 } 7190 }
7184 } 7191 }
(...skipping 5257 matching lines...) Expand 10 before | Expand all | Expand 10 after
12442 MaybeHandle<AccessorPair> JSObject::GetLocalPropertyAccessorPair( 12449 MaybeHandle<AccessorPair> JSObject::GetLocalPropertyAccessorPair(
12443 Handle<JSObject> object, 12450 Handle<JSObject> object,
12444 Handle<Name> name) { 12451 Handle<Name> name) {
12445 uint32_t index = 0; 12452 uint32_t index = 0;
12446 if (name->AsArrayIndex(&index)) { 12453 if (name->AsArrayIndex(&index)) {
12447 return GetLocalElementAccessorPair(object, index); 12454 return GetLocalElementAccessorPair(object, index);
12448 } 12455 }
12449 12456
12450 Isolate* isolate = object->GetIsolate(); 12457 Isolate* isolate = object->GetIsolate();
12451 LookupResult lookup(isolate); 12458 LookupResult lookup(isolate);
12452 object->LocalLookupRealNamedProperty(*name, &lookup); 12459 object->LocalLookupRealNamedProperty(name, &lookup);
12453 12460
12454 if (lookup.IsPropertyCallbacks() && 12461 if (lookup.IsPropertyCallbacks() &&
12455 lookup.GetCallbackObject()->IsAccessorPair()) { 12462 lookup.GetCallbackObject()->IsAccessorPair()) {
12456 return handle(AccessorPair::cast(lookup.GetCallbackObject()), isolate); 12463 return handle(AccessorPair::cast(lookup.GetCallbackObject()), isolate);
12457 } 12464 }
12458 return MaybeHandle<AccessorPair>(); 12465 return MaybeHandle<AccessorPair>();
12459 } 12466 }
12460 12467
12461 12468
12462 MaybeHandle<AccessorPair> JSObject::GetLocalElementAccessorPair( 12469 MaybeHandle<AccessorPair> JSObject::GetLocalElementAccessorPair(
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
13766 13773
13767 13774
13768 MaybeHandle<Object> JSObject::GetPropertyPostInterceptor( 13775 MaybeHandle<Object> JSObject::GetPropertyPostInterceptor(
13769 Handle<JSObject> object, 13776 Handle<JSObject> object,
13770 Handle<Object> receiver, 13777 Handle<Object> receiver,
13771 Handle<Name> name, 13778 Handle<Name> name,
13772 PropertyAttributes* attributes) { 13779 PropertyAttributes* attributes) {
13773 // Check local property in holder, ignore interceptor. 13780 // Check local property in holder, ignore interceptor.
13774 Isolate* isolate = object->GetIsolate(); 13781 Isolate* isolate = object->GetIsolate();
13775 LookupResult lookup(isolate); 13782 LookupResult lookup(isolate);
13776 object->LocalLookupRealNamedProperty(*name, &lookup); 13783 object->LocalLookupRealNamedProperty(name, &lookup);
13777 if (lookup.IsFound()) { 13784 if (lookup.IsFound()) {
13778 return GetProperty(object, receiver, &lookup, name, attributes); 13785 return GetProperty(object, receiver, &lookup, name, attributes);
13779 } else { 13786 } else {
13780 // Continue searching via the prototype chain. 13787 // Continue searching via the prototype chain.
13781 Handle<Object> prototype(object->GetPrototype(), isolate); 13788 Handle<Object> prototype(object->GetPrototype(), isolate);
13782 *attributes = ABSENT; 13789 *attributes = ABSENT;
13783 if (prototype->IsNull()) return isolate->factory()->undefined_value(); 13790 if (prototype->IsNull()) return isolate->factory()->undefined_value();
13784 return GetPropertyWithReceiver(prototype, receiver, name, attributes); 13791 return GetPropertyWithReceiver(prototype, receiver, name, attributes);
13785 } 13792 }
13786 } 13793 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
13880 // Check access rights if needed. 13887 // Check access rights if needed.
13881 if (object->IsAccessCheckNeeded()) { 13888 if (object->IsAccessCheckNeeded()) {
13882 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { 13889 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
13883 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); 13890 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
13884 // TODO(yangguo): Issue 3269, check for scheduled exception missing? 13891 // TODO(yangguo): Issue 3269, check for scheduled exception missing?
13885 return false; 13892 return false;
13886 } 13893 }
13887 } 13894 }
13888 13895
13889 LookupResult result(isolate); 13896 LookupResult result(isolate);
13890 object->LocalLookupRealNamedProperty(*key, &result); 13897 object->LocalLookupRealNamedProperty(key, &result);
13891 return result.IsFound() && !result.IsInterceptor(); 13898 return result.IsFound() && !result.IsInterceptor();
13892 } 13899 }
13893 13900
13894 13901
13895 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { 13902 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) {
13896 Isolate* isolate = object->GetIsolate(); 13903 Isolate* isolate = object->GetIsolate();
13897 HandleScope scope(isolate); 13904 HandleScope scope(isolate);
13898 // Check access rights if needed. 13905 // Check access rights if needed.
13899 if (object->IsAccessCheckNeeded()) { 13906 if (object->IsAccessCheckNeeded()) {
13900 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { 13907 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) {
(...skipping 23 matching lines...) Expand all
13924 // Check access rights if needed. 13931 // Check access rights if needed.
13925 if (object->IsAccessCheckNeeded()) { 13932 if (object->IsAccessCheckNeeded()) {
13926 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { 13933 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
13927 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); 13934 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
13928 // TODO(yangguo): Issue 3269, check for scheduled exception missing? 13935 // TODO(yangguo): Issue 3269, check for scheduled exception missing?
13929 return false; 13936 return false;
13930 } 13937 }
13931 } 13938 }
13932 13939
13933 LookupResult result(isolate); 13940 LookupResult result(isolate);
13934 object->LocalLookupRealNamedProperty(*key, &result); 13941 object->LocalLookupRealNamedProperty(key, &result);
13935 return result.IsPropertyCallbacks(); 13942 return result.IsPropertyCallbacks();
13936 } 13943 }
13937 13944
13938 13945
13939 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { 13946 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
13940 if (HasFastProperties()) { 13947 if (HasFastProperties()) {
13941 Map* map = this->map(); 13948 Map* map = this->map();
13942 if (filter == NONE) return map->NumberOfOwnDescriptors(); 13949 if (filter == NONE) return map->NumberOfOwnDescriptors();
13943 if (filter & DONT_ENUM) { 13950 if (filter & DONT_ENUM) {
13944 int result = map->EnumLength(); 13951 int result = map->EnumLength();
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
14525 array->set_map_no_write_barrier(*factory->hash_table_map()); 14532 array->set_map_no_write_barrier(*factory->hash_table_map());
14526 Handle<Derived> table = Handle<Derived>::cast(array); 14533 Handle<Derived> table = Handle<Derived>::cast(array);
14527 14534
14528 table->SetNumberOfElements(0); 14535 table->SetNumberOfElements(0);
14529 table->SetNumberOfDeletedElements(0); 14536 table->SetNumberOfDeletedElements(0);
14530 table->SetCapacity(capacity); 14537 table->SetCapacity(capacity);
14531 return table; 14538 return table;
14532 } 14539 }
14533 14540
14534 14541
14535 // TODO(ishell): Remove this when all the callers are handlified.
14536 int NameDictionary::FindEntry(Name* key) {
14537 DisallowHeapAllocation no_allocation;
14538 Isolate* isolate = key->GetIsolate();
14539 HandleScope scope(isolate);
14540 return FindEntry(handle(key, isolate));
14541 }
14542
14543
14544 // Find entry for key otherwise return kNotFound. 14542 // Find entry for key otherwise return kNotFound.
14545 int NameDictionary::FindEntry(Handle<Name> key) { 14543 int NameDictionary::FindEntry(Handle<Name> key) {
14546 if (!key->IsUniqueName()) { 14544 if (!key->IsUniqueName()) {
14547 return DerivedHashTable::FindEntry(key); 14545 return DerivedHashTable::FindEntry(key);
14548 } 14546 }
14549 14547
14550 // Optimized for unique names. Knowledge of the key type allows: 14548 // Optimized for unique names. Knowledge of the key type allows:
14551 // 1. Move the check if the key is unique out of the loop. 14549 // 1. Move the check if the key is unique out of the loop.
14552 // 2. Avoid comparing hash codes in unique-to-unique comparison. 14550 // 2. Avoid comparing hash codes in unique-to-unique comparison.
14553 // 3. Detect a case when a dictionary key is not unique but the key is. 14551 // 3. Detect a case when a dictionary key is not unique but the key is.
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after
17253 #define ERROR_MESSAGES_TEXTS(C, T) T, 17251 #define ERROR_MESSAGES_TEXTS(C, T) T,
17254 static const char* error_messages_[] = { 17252 static const char* error_messages_[] = {
17255 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17253 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17256 }; 17254 };
17257 #undef ERROR_MESSAGES_TEXTS 17255 #undef ERROR_MESSAGES_TEXTS
17258 return error_messages_[reason]; 17256 return error_messages_[reason];
17259 } 17257 }
17260 17258
17261 17259
17262 } } // namespace v8::internal 17260 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698