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

Side by Side Diff: src/objects.cc

Issue 10736009: Fix inline constructors for Harmony Proxy prototypes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 8 years, 5 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 | « no previous file | 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 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 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
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 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after
7788 7788
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.
7799 if (!prototype->IsJSObject()) {
7800 ASSERT(prototype->IsNull());
7801 return true;
7802 }
7803
7804 Heap* heap = GetHeap(); 7798 Heap* heap = GetHeap();
7805 7799
7806 // Traverse the proposed prototype chain looking for setters for properties of 7800 // Traverse the proposed prototype chain looking for properties of the
7807 // the same names as are set by the inline constructor. 7801 // same names as are set by the inline constructor.
7808 for (Object* obj = prototype; 7802 for (Object* obj = prototype;
7809 obj != heap->null_value(); 7803 obj != heap->null_value();
7810 obj = obj->GetPrototype()) { 7804 obj = obj->GetPrototype()) {
7811 JSObject* js_object = JSObject::cast(obj); 7805 JSReceiver* receiver = JSReceiver::cast(obj);
7812 for (int i = 0; i < this_property_assignments_count(); i++) { 7806 for (int i = 0; i < this_property_assignments_count(); i++) {
7813 LookupResult result(heap->isolate()); 7807 LookupResult result(heap->isolate());
7814 String* name = GetThisPropertyAssignmentName(i); 7808 String* name = GetThisPropertyAssignmentName(i);
7815 js_object->LocalLookupRealNamedProperty(name, &result); 7809 receiver->LocalLookup(name, &result);
7816 if (result.IsCallbacks()) return false; 7810 if (result.IsProperty()) {
7811 switch (result.type()) {
7812 case NORMAL:
7813 case FIELD:
7814 case CONSTANT_FUNCTION:
7815 break;
7816 case INTERCEPTOR:
7817 case CALLBACKS:
7818 case HANDLER:
7819 return false;
7820 case TRANSITION:
7821 case NONEXISTENT:
7822 UNREACHABLE();
7823 break;
7824 }
7825 }
7817 } 7826 }
7818 } 7827 }
7819 7828
7820 return true; 7829 return true;
7821 } 7830 }
7822 7831
7823 7832
7824 void SharedFunctionInfo::ForbidInlineConstructor() { 7833 void SharedFunctionInfo::ForbidInlineConstructor() {
7825 set_compiler_hints(BooleanBit::set(compiler_hints(), 7834 set_compiler_hints(BooleanBit::set(compiler_hints(),
7826 kHasOnlySimpleThisPropertyAssignments, 7835 kHasOnlySimpleThisPropertyAssignments,
(...skipping 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after
13276 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13285 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13277 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13286 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13278 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13287 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13279 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13288 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13280 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13289 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13281 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13290 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13282 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13291 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13283 } 13292 }
13284 13293
13285 } } // namespace v8::internal 13294 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698