OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 if (r.IsProperty()) { | 409 if (r.IsProperty()) { |
410 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 410 return GetPropertyAttributeWithFailedAccessCheck(receiver, |
411 &r, | 411 &r, |
412 name, | 412 name, |
413 continue_search); | 413 continue_search); |
414 } | 414 } |
415 break; | 415 break; |
416 } | 416 } |
417 | 417 |
418 default: | 418 case HANDLER: |
| 419 case MAP_TRANSITION: |
| 420 case CONSTANT_TRANSITION: |
| 421 case NONEXISTENT: |
419 UNREACHABLE(); | 422 UNREACHABLE(); |
420 } | 423 } |
421 } | 424 } |
422 | 425 |
423 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 426 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
424 return ABSENT; | 427 return ABSENT; |
425 } | 428 } |
426 | 429 |
427 | 430 |
428 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 431 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); | 2413 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); |
2411 } | 2414 } |
2412 | 2415 |
2413 if (HasFastProperties()) { | 2416 if (HasFastProperties()) { |
2414 LookupInDescriptor(name, result); | 2417 LookupInDescriptor(name, result); |
2415 if (result->IsFound()) { | 2418 if (result->IsFound()) { |
2416 // A property, a map transition or a null descriptor was found. | 2419 // A property, a map transition or a null descriptor was found. |
2417 // We return all of these result types because | 2420 // We return all of these result types because |
2418 // LocalLookupRealNamedProperty is used when setting properties | 2421 // LocalLookupRealNamedProperty is used when setting properties |
2419 // where map transitions and null descriptors are handled. | 2422 // where map transitions and null descriptors are handled. |
2420 ASSERT(result->holder() == this && result->type() != NORMAL); | 2423 ASSERT(result->holder() == this && result->IsFastPropertyType()); |
2421 // Disallow caching for uninitialized constants. These can only | 2424 // Disallow caching for uninitialized constants. These can only |
2422 // occur as fields. | 2425 // occur as fields. |
2423 if (result->IsReadOnly() && result->type() == FIELD && | 2426 if (result->IsField() && |
| 2427 result->IsReadOnly() && |
2424 FastPropertyAt(result->GetFieldIndex())->IsTheHole()) { | 2428 FastPropertyAt(result->GetFieldIndex())->IsTheHole()) { |
2425 result->DisallowCaching(); | 2429 result->DisallowCaching(); |
2426 } | 2430 } |
2427 return; | 2431 return; |
2428 } | 2432 } |
2429 } else { | 2433 } else { |
2430 int entry = property_dictionary()->FindEntry(name); | 2434 int entry = property_dictionary()->FindEntry(name); |
2431 if (entry != StringDictionary::kNotFound) { | 2435 if (entry != StringDictionary::kNotFound) { |
2432 Object* value = property_dictionary()->ValueAt(entry); | 2436 Object* value = property_dictionary()->ValueAt(entry); |
2433 if (IsGlobalObject()) { | 2437 if (IsGlobalObject()) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 return *value_handle; | 2534 return *value_handle; |
2531 } | 2535 } |
2532 | 2536 |
2533 | 2537 |
2534 MaybeObject* JSReceiver::SetProperty(LookupResult* result, | 2538 MaybeObject* JSReceiver::SetProperty(LookupResult* result, |
2535 String* key, | 2539 String* key, |
2536 Object* value, | 2540 Object* value, |
2537 PropertyAttributes attributes, | 2541 PropertyAttributes attributes, |
2538 StrictModeFlag strict_mode, | 2542 StrictModeFlag strict_mode, |
2539 JSReceiver::StoreFromKeyed store_mode) { | 2543 JSReceiver::StoreFromKeyed store_mode) { |
2540 if (result->IsFound() && result->type() == HANDLER) { | 2544 if (result->IsHandler()) { |
2541 return result->proxy()->SetPropertyWithHandler( | 2545 return result->proxy()->SetPropertyWithHandler( |
2542 this, key, value, attributes, strict_mode); | 2546 this, key, value, attributes, strict_mode); |
2543 } else { | 2547 } else { |
2544 return JSObject::cast(this)->SetPropertyForResult( | 2548 return JSObject::cast(this)->SetPropertyForResult( |
2545 result, key, value, attributes, strict_mode, store_mode); | 2549 result, key, value, attributes, strict_mode, store_mode); |
2546 } | 2550 } |
2547 } | 2551 } |
2548 | 2552 |
2549 | 2553 |
2550 bool JSProxy::HasPropertyWithHandler(String* name_raw) { | 2554 bool JSProxy::HasPropertyWithHandler(String* name_raw) { |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3901 if (mode == STRICT_DELETION) { | 3905 if (mode == STRICT_DELETION) { |
3902 // Deleting a non-configurable property in strict mode. | 3906 // Deleting a non-configurable property in strict mode. |
3903 HandleScope scope(isolate); | 3907 HandleScope scope(isolate); |
3904 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; | 3908 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; |
3905 return isolate->Throw(*isolate->factory()->NewTypeError( | 3909 return isolate->Throw(*isolate->factory()->NewTypeError( |
3906 "strict_delete_property", HandleVector(args, 2))); | 3910 "strict_delete_property", HandleVector(args, 2))); |
3907 } | 3911 } |
3908 return isolate->heap()->false_value(); | 3912 return isolate->heap()->false_value(); |
3909 } | 3913 } |
3910 // Check for interceptor. | 3914 // Check for interceptor. |
3911 if (result.type() == INTERCEPTOR) { | 3915 if (result.IsInterceptor()) { |
3912 // Skip interceptor if forcing a deletion. | 3916 // Skip interceptor if forcing a deletion. |
3913 if (mode == FORCE_DELETION) { | 3917 if (mode == FORCE_DELETION) { |
3914 return DeletePropertyPostInterceptor(name, mode); | 3918 return DeletePropertyPostInterceptor(name, mode); |
3915 } | 3919 } |
3916 return DeletePropertyWithInterceptor(name); | 3920 return DeletePropertyWithInterceptor(name); |
3917 } | 3921 } |
3918 // Normalize object if needed. | 3922 // Normalize object if needed. |
3919 Object* obj; | 3923 Object* obj; |
3920 { MaybeObject* maybe_obj = | 3924 { MaybeObject* maybe_obj = |
3921 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 3925 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4260 } | 4264 } |
4261 | 4265 |
4262 | 4266 |
4263 // Search object and its prototype chain for callback properties. | 4267 // Search object and its prototype chain for callback properties. |
4264 void JSObject::LookupCallback(String* name, LookupResult* result) { | 4268 void JSObject::LookupCallback(String* name, LookupResult* result) { |
4265 Heap* heap = GetHeap(); | 4269 Heap* heap = GetHeap(); |
4266 for (Object* current = this; | 4270 for (Object* current = this; |
4267 current != heap->null_value() && current->IsJSObject(); | 4271 current != heap->null_value() && current->IsJSObject(); |
4268 current = JSObject::cast(current)->GetPrototype()) { | 4272 current = JSObject::cast(current)->GetPrototype()) { |
4269 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); | 4273 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); |
4270 if (result->IsFound() && result->type() == CALLBACKS) return; | 4274 if (result->IsCallbacks()) return; |
4271 } | 4275 } |
4272 result->NotFound(); | 4276 result->NotFound(); |
4273 } | 4277 } |
4274 | 4278 |
4275 | 4279 |
4276 // Try to update an accessor in an elements dictionary. Return true if the | 4280 // Try to update an accessor in an elements dictionary. Return true if the |
4277 // update succeeded, and false otherwise. | 4281 // update succeeded, and false otherwise. |
4278 static bool UpdateGetterSetterInDictionary( | 4282 static bool UpdateGetterSetterInDictionary( |
4279 SeededNumberDictionary* dictionary, | 4283 SeededNumberDictionary* dictionary, |
4280 uint32_t index, | 4284 uint32_t index, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4363 } | 4367 } |
4364 accessors->SetComponents(getter, setter); | 4368 accessors->SetComponents(getter, setter); |
4365 | 4369 |
4366 return SetElementCallback(index, accessors, attributes); | 4370 return SetElementCallback(index, accessors, attributes); |
4367 } | 4371 } |
4368 | 4372 |
4369 | 4373 |
4370 MaybeObject* JSObject::CreateAccessorPairFor(String* name) { | 4374 MaybeObject* JSObject::CreateAccessorPairFor(String* name) { |
4371 LookupResult result(GetHeap()->isolate()); | 4375 LookupResult result(GetHeap()->isolate()); |
4372 LocalLookupRealNamedProperty(name, &result); | 4376 LocalLookupRealNamedProperty(name, &result); |
4373 if (result.IsProperty() && result.type() == CALLBACKS) { | 4377 if (result.IsProperty() && result.IsCallbacks()) { |
4374 // Note that the result can actually have IsDontDelete() == true when we | 4378 // Note that the result can actually have IsDontDelete() == true when we |
4375 // e.g. have to fall back to the slow case while adding a setter after | 4379 // e.g. have to fall back to the slow case while adding a setter after |
4376 // successfully reusing a map transition for a getter. Nevertheless, this is | 4380 // successfully reusing a map transition for a getter. Nevertheless, this is |
4377 // OK, because the assertion only holds for the whole addition of both | 4381 // OK, because the assertion only holds for the whole addition of both |
4378 // accessors, not for the addition of each part. See first comment in | 4382 // accessors, not for the addition of each part. See first comment in |
4379 // DefinePropertyAccessor below. | 4383 // DefinePropertyAccessor below. |
4380 Object* obj = result.GetCallbackObject(); | 4384 Object* obj = result.GetCallbackObject(); |
4381 if (obj->IsAccessorPair()) { | 4385 if (obj->IsAccessorPair()) { |
4382 return AccessorPair::cast(obj)->CopyWithoutTransitions(); | 4386 return AccessorPair::cast(obj)->CopyWithoutTransitions(); |
4383 } | 4387 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4833 } | 4837 } |
4834 } | 4838 } |
4835 } else { | 4839 } else { |
4836 for (Object* obj = this; | 4840 for (Object* obj = this; |
4837 obj != heap->null_value(); | 4841 obj != heap->null_value(); |
4838 obj = JSObject::cast(obj)->GetPrototype()) { | 4842 obj = JSObject::cast(obj)->GetPrototype()) { |
4839 LookupResult result(heap->isolate()); | 4843 LookupResult result(heap->isolate()); |
4840 JSObject::cast(obj)->LocalLookup(name, &result); | 4844 JSObject::cast(obj)->LocalLookup(name, &result); |
4841 if (result.IsProperty()) { | 4845 if (result.IsProperty()) { |
4842 if (result.IsReadOnly()) return heap->undefined_value(); | 4846 if (result.IsReadOnly()) return heap->undefined_value(); |
4843 if (result.type() == CALLBACKS) { | 4847 if (result.IsCallbacks()) { |
4844 Object* obj = result.GetCallbackObject(); | 4848 Object* obj = result.GetCallbackObject(); |
4845 if (obj->IsAccessorPair()) { | 4849 if (obj->IsAccessorPair()) { |
4846 return AccessorPair::cast(obj)->GetComponent(component); | 4850 return AccessorPair::cast(obj)->GetComponent(component); |
4847 } | 4851 } |
4848 } | 4852 } |
4849 } | 4853 } |
4850 } | 4854 } |
4851 } | 4855 } |
4852 return heap->undefined_value(); | 4856 return heap->undefined_value(); |
4853 } | 4857 } |
(...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7781 // Traverse the proposed prototype chain looking for setters for properties of | 7785 // Traverse the proposed prototype chain looking for setters for properties of |
7782 // the same names as are set by the inline constructor. | 7786 // the same names as are set by the inline constructor. |
7783 for (Object* obj = prototype; | 7787 for (Object* obj = prototype; |
7784 obj != heap->null_value(); | 7788 obj != heap->null_value(); |
7785 obj = obj->GetPrototype()) { | 7789 obj = obj->GetPrototype()) { |
7786 JSObject* js_object = JSObject::cast(obj); | 7790 JSObject* js_object = JSObject::cast(obj); |
7787 for (int i = 0; i < this_property_assignments_count(); i++) { | 7791 for (int i = 0; i < this_property_assignments_count(); i++) { |
7788 LookupResult result(heap->isolate()); | 7792 LookupResult result(heap->isolate()); |
7789 String* name = GetThisPropertyAssignmentName(i); | 7793 String* name = GetThisPropertyAssignmentName(i); |
7790 js_object->LocalLookupRealNamedProperty(name, &result); | 7794 js_object->LocalLookupRealNamedProperty(name, &result); |
7791 if (result.IsFound() && result.type() == CALLBACKS) { | 7795 if (result.IsCallbacks()) return false; |
7792 return false; | |
7793 } | |
7794 } | 7796 } |
7795 } | 7797 } |
7796 | 7798 |
7797 return true; | 7799 return true; |
7798 } | 7800 } |
7799 | 7801 |
7800 | 7802 |
7801 void SharedFunctionInfo::ForbidInlineConstructor() { | 7803 void SharedFunctionInfo::ForbidInlineConstructor() { |
7802 set_compiler_hints(BooleanBit::set(compiler_hints(), | 7804 set_compiler_hints(BooleanBit::set(compiler_hints(), |
7803 kHasOnlySimpleThisPropertyAssignments, | 7805 kHasOnlySimpleThisPropertyAssignments, |
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10378 Isolate* isolate = GetIsolate(); | 10380 Isolate* isolate = GetIsolate(); |
10379 if (IsAccessCheckNeeded()) { | 10381 if (IsAccessCheckNeeded()) { |
10380 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 10382 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
10381 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 10383 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
10382 return false; | 10384 return false; |
10383 } | 10385 } |
10384 } | 10386 } |
10385 | 10387 |
10386 LookupResult result(isolate); | 10388 LookupResult result(isolate); |
10387 LocalLookupRealNamedProperty(key, &result); | 10389 LocalLookupRealNamedProperty(key, &result); |
10388 return result.IsProperty() && (result.type() != INTERCEPTOR); | 10390 return result.IsProperty() && !result.IsInterceptor(); |
10389 } | 10391 } |
10390 | 10392 |
10391 | 10393 |
10392 bool JSObject::HasRealElementProperty(uint32_t index) { | 10394 bool JSObject::HasRealElementProperty(uint32_t index) { |
10393 // Check access rights if needed. | 10395 // Check access rights if needed. |
10394 if (IsAccessCheckNeeded()) { | 10396 if (IsAccessCheckNeeded()) { |
10395 Heap* heap = GetHeap(); | 10397 Heap* heap = GetHeap(); |
10396 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 10398 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
10397 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 10399 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
10398 return false; | 10400 return false; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10458 Isolate* isolate = GetIsolate(); | 10460 Isolate* isolate = GetIsolate(); |
10459 if (IsAccessCheckNeeded()) { | 10461 if (IsAccessCheckNeeded()) { |
10460 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 10462 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
10461 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 10463 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
10462 return false; | 10464 return false; |
10463 } | 10465 } |
10464 } | 10466 } |
10465 | 10467 |
10466 LookupResult result(isolate); | 10468 LookupResult result(isolate); |
10467 LocalLookupRealNamedProperty(key, &result); | 10469 LocalLookupRealNamedProperty(key, &result); |
10468 return result.IsFound() && (result.type() == CALLBACKS); | 10470 return result.IsCallbacks(); |
10469 } | 10471 } |
10470 | 10472 |
10471 | 10473 |
10472 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { | 10474 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { |
10473 return HasFastProperties() ? | 10475 return HasFastProperties() ? |
10474 map()->NumberOfDescribedProperties(filter) : | 10476 map()->NumberOfDescribedProperties(filter) : |
10475 property_dictionary()->NumberOfElementsFilterAttributes(filter); | 10477 property_dictionary()->NumberOfElementsFilterAttributes(filter); |
10476 } | 10478 } |
10477 | 10479 |
10478 | 10480 |
(...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13278 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13280 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13279 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13281 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13280 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13282 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13281 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13283 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13282 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13284 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13283 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13285 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13284 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13286 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13285 } | 13287 } |
13286 | 13288 |
13287 } } // namespace v8::internal | 13289 } } // namespace v8::internal |
OLD | NEW |