Chromium Code Reviews| 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 4843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4854 if (IsAccessCheckNeeded() && | 4854 if (IsAccessCheckNeeded() && |
| 4855 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { | 4855 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { |
| 4856 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 4856 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 4857 return heap->undefined_value(); | 4857 return heap->undefined_value(); |
| 4858 } | 4858 } |
| 4859 | 4859 |
| 4860 // Make the lookup and include prototypes. | 4860 // Make the lookup and include prototypes. |
| 4861 uint32_t index = 0; | 4861 uint32_t index = 0; |
| 4862 if (name->AsArrayIndex(&index)) { | 4862 if (name->AsArrayIndex(&index)) { |
| 4863 for (Object* obj = this; | 4863 for (Object* obj = this; |
| 4864 obj != heap->null_value(); | 4864 obj != heap->null_value(); |
|
rossberg
2012/07/10 11:08:14
While you're at it, can you replace this with !obj
Michael Starzinger
2012/07/10 11:24:50
As discussed offline: I'll keep the pointer compar
| |
| 4865 obj = JSObject::cast(obj)->GetPrototype()) { | 4865 obj = JSReceiver::cast(obj)->GetPrototype()) { |
| 4866 JSObject* js_object = JSObject::cast(obj); | 4866 if (obj->IsJSObject() && JSObject::cast(obj)->HasDictionaryElements()) { |
| 4867 if (js_object->HasDictionaryElements()) { | 4867 JSObject* js_object = JSObject::cast(obj); |
| 4868 SeededNumberDictionary* dictionary = js_object->element_dictionary(); | 4868 SeededNumberDictionary* dictionary = js_object->element_dictionary(); |
| 4869 int entry = dictionary->FindEntry(index); | 4869 int entry = dictionary->FindEntry(index); |
| 4870 if (entry != SeededNumberDictionary::kNotFound) { | 4870 if (entry != SeededNumberDictionary::kNotFound) { |
| 4871 Object* element = dictionary->ValueAt(entry); | 4871 Object* element = dictionary->ValueAt(entry); |
| 4872 if (dictionary->DetailsAt(entry).type() == CALLBACKS && | 4872 if (dictionary->DetailsAt(entry).type() == CALLBACKS && |
| 4873 element->IsAccessorPair()) { | 4873 element->IsAccessorPair()) { |
| 4874 return AccessorPair::cast(element)->GetComponent(component); | 4874 return AccessorPair::cast(element)->GetComponent(component); |
| 4875 } | 4875 } |
| 4876 } | 4876 } |
| 4877 } | 4877 } |
| 4878 } | 4878 } |
| 4879 } else { | 4879 } else { |
| 4880 for (Object* obj = this; | 4880 for (Object* obj = this; |
| 4881 obj != heap->null_value(); | 4881 obj != heap->null_value(); |
| 4882 obj = JSObject::cast(obj)->GetPrototype()) { | 4882 obj = JSReceiver::cast(obj)->GetPrototype()) { |
| 4883 LookupResult result(heap->isolate()); | 4883 LookupResult result(heap->isolate()); |
| 4884 JSObject::cast(obj)->LocalLookup(name, &result); | 4884 JSReceiver::cast(obj)->LocalLookup(name, &result); |
| 4885 if (result.IsProperty()) { | 4885 if (result.IsProperty()) { |
| 4886 if (result.IsReadOnly()) return heap->undefined_value(); | 4886 if (result.IsReadOnly()) return heap->undefined_value(); |
| 4887 if (result.IsPropertyCallbacks()) { | 4887 if (result.IsPropertyCallbacks()) { |
| 4888 Object* obj = result.GetCallbackObject(); | 4888 Object* obj = result.GetCallbackObject(); |
| 4889 if (obj->IsAccessorPair()) { | 4889 if (obj->IsAccessorPair()) { |
| 4890 return AccessorPair::cast(obj)->GetComponent(component); | 4890 return AccessorPair::cast(obj)->GetComponent(component); |
| 4891 } | 4891 } |
| 4892 } | 4892 } |
| 4893 } | 4893 } |
| 4894 } | 4894 } |
| (...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7789 | 7789 |
| 7790 bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) { | 7790 bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) { |
| 7791 // Check the basic conditions for generating inline constructor code. | 7791 // Check the basic conditions for generating inline constructor code. |
| 7792 if (!FLAG_inline_new | 7792 if (!FLAG_inline_new |
| 7793 || !has_only_simple_this_property_assignments() | 7793 || !has_only_simple_this_property_assignments() |
| 7794 || this_property_assignments_count() == 0) { | 7794 || this_property_assignments_count() == 0) { |
| 7795 return false; | 7795 return false; |
| 7796 } | 7796 } |
| 7797 | 7797 |
| 7798 // If the prototype is null inline constructors cause no problems. | 7798 // If the prototype is null inline constructors cause no problems. |
| 7799 if (!prototype->IsJSObject()) { | 7799 if (!prototype->IsJSReceiver()) { |
|
rossberg
2012/07/10 11:08:14
Do we still need this conditional at all? AFAICS,
Michael Starzinger
2012/07/10 11:24:50
Done.
| |
| 7800 ASSERT(prototype->IsNull()); | 7800 ASSERT(prototype->IsNull()); |
| 7801 return true; | 7801 return true; |
| 7802 } | 7802 } |
| 7803 | 7803 |
| 7804 Heap* heap = GetHeap(); | 7804 Heap* heap = GetHeap(); |
| 7805 | 7805 |
| 7806 // Traverse the proposed prototype chain looking for setters for properties of | 7806 // Traverse the proposed prototype chain looking for properties of the |
| 7807 // the same names as are set by the inline constructor. | 7807 // same names as are set by the inline constructor. |
| 7808 for (Object* obj = prototype; | 7808 for (Object* obj = prototype; |
| 7809 obj != heap->null_value(); | 7809 obj != heap->null_value(); |
| 7810 obj = obj->GetPrototype()) { | 7810 obj = obj->GetPrototype()) { |
| 7811 JSObject* js_object = JSObject::cast(obj); | 7811 JSReceiver* receiver = JSReceiver::cast(obj); |
| 7812 for (int i = 0; i < this_property_assignments_count(); i++) { | 7812 for (int i = 0; i < this_property_assignments_count(); i++) { |
| 7813 LookupResult result(heap->isolate()); | 7813 LookupResult result(heap->isolate()); |
| 7814 String* name = GetThisPropertyAssignmentName(i); | 7814 String* name = GetThisPropertyAssignmentName(i); |
| 7815 js_object->LocalLookupRealNamedProperty(name, &result); | 7815 receiver->LocalLookup(name, &result); |
| 7816 if (result.IsCallbacks()) return false; | 7816 if (result.IsProperty()) { |
| 7817 switch (result.type()) { | |
| 7818 case NORMAL: | |
| 7819 case FIELD: | |
| 7820 case CONSTANT_FUNCTION: | |
| 7821 break; | |
| 7822 case INTERCEPTOR: | |
| 7823 case CALLBACKS: | |
| 7824 case HANDLER: | |
| 7825 return false; | |
| 7826 case TRANSITION: | |
| 7827 case NONEXISTENT: | |
| 7828 UNREACHABLE(); | |
| 7829 break; | |
| 7830 } | |
| 7831 } | |
| 7817 } | 7832 } |
| 7818 } | 7833 } |
| 7819 | 7834 |
| 7820 return true; | 7835 return true; |
| 7821 } | 7836 } |
| 7822 | 7837 |
| 7823 | 7838 |
| 7824 void SharedFunctionInfo::ForbidInlineConstructor() { | 7839 void SharedFunctionInfo::ForbidInlineConstructor() { |
| 7825 set_compiler_hints(BooleanBit::set(compiler_hints(), | 7840 set_compiler_hints(BooleanBit::set(compiler_hints(), |
| 7826 kHasOnlySimpleThisPropertyAssignments, | 7841 kHasOnlySimpleThisPropertyAssignments, |
| (...skipping 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13276 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13291 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13277 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13292 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13278 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13293 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13279 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13294 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13280 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13295 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13281 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13296 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13282 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13297 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13283 } | 13298 } |
| 13284 | 13299 |
| 13285 } } // namespace v8::internal | 13300 } } // namespace v8::internal |
| OLD | NEW |