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

Side by Side Diff: src/objects.cc

Issue 570293002: Simplify the LookupIterator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/lookup-inl.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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 (fun->IsHeapObject() && 103 (fun->IsHeapObject() &&
104 HeapObject::cast(fun)->map()->has_instance_call_handler()); 104 HeapObject::cast(fun)->map()->has_instance_call_handler());
105 } 105 }
106 106
107 107
108 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) { 108 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
109 for (; it->IsFound(); it->Next()) { 109 for (; it->IsFound(); it->Next()) {
110 switch (it->state()) { 110 switch (it->state()) {
111 case LookupIterator::NOT_FOUND: 111 case LookupIterator::NOT_FOUND:
112 case LookupIterator::TRANSITION: 112 case LookupIterator::TRANSITION:
113 case LookupIterator::UNKNOWN:
114 UNREACHABLE(); 113 UNREACHABLE();
115 case LookupIterator::JSPROXY: 114 case LookupIterator::JSPROXY:
116 return JSProxy::GetPropertyWithHandler(it->GetHolder<JSProxy>(), 115 return JSProxy::GetPropertyWithHandler(it->GetHolder<JSProxy>(),
117 it->GetReceiver(), it->name()); 116 it->GetReceiver(), it->name());
118 case LookupIterator::INTERCEPTOR: { 117 case LookupIterator::INTERCEPTOR: {
119 MaybeHandle<Object> maybe_result = JSObject::GetPropertyWithInterceptor( 118 MaybeHandle<Object> maybe_result = JSObject::GetPropertyWithInterceptor(
120 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 119 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
121 if (!maybe_result.is_null()) return maybe_result; 120 if (!maybe_result.is_null()) return maybe_result;
122 if (it->isolate()->has_pending_exception()) return maybe_result; 121 if (it->isolate()->has_pending_exception()) return maybe_result;
123 break; 122 break;
(...skipping 20 matching lines...) Expand all
144 return GetDataProperty(&it); 143 return GetDataProperty(&it);
145 } 144 }
146 145
147 146
148 Handle<Object> JSObject::GetDataProperty(LookupIterator* it) { 147 Handle<Object> JSObject::GetDataProperty(LookupIterator* it) {
149 for (; it->IsFound(); it->Next()) { 148 for (; it->IsFound(); it->Next()) {
150 switch (it->state()) { 149 switch (it->state()) {
151 case LookupIterator::INTERCEPTOR: 150 case LookupIterator::INTERCEPTOR:
152 case LookupIterator::NOT_FOUND: 151 case LookupIterator::NOT_FOUND:
153 case LookupIterator::TRANSITION: 152 case LookupIterator::TRANSITION:
154 case LookupIterator::UNKNOWN:
155 UNREACHABLE(); 153 UNREACHABLE();
156 case LookupIterator::ACCESS_CHECK: 154 case LookupIterator::ACCESS_CHECK:
157 if (it->HasAccess(v8::ACCESS_GET)) continue; 155 if (it->HasAccess(v8::ACCESS_GET)) continue;
158 // Fall through. 156 // Fall through.
159 case LookupIterator::JSPROXY: 157 case LookupIterator::JSPROXY:
160 it->NotFound(); 158 it->NotFound();
161 return it->isolate()->factory()->undefined_value(); 159 return it->isolate()->factory()->undefined_value();
162 case LookupIterator::ACCESSOR: 160 case LookupIterator::ACCESSOR:
163 // TODO(verwaest): For now this doesn't call into 161 // TODO(verwaest): For now this doesn't call into
164 // ExecutableAccessorInfo, since clients don't need it. Update once 162 // ExecutableAccessorInfo, since clients don't need it. Update once
(...skipping 2634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2799 StrictMode strict_mode, 2797 StrictMode strict_mode,
2800 StoreFromKeyed store_mode) { 2798 StoreFromKeyed store_mode) {
2801 // Make sure that the top context does not change when doing callbacks or 2799 // Make sure that the top context does not change when doing callbacks or
2802 // interceptor calls. 2800 // interceptor calls.
2803 AssertNoContextChange ncc(it->isolate()); 2801 AssertNoContextChange ncc(it->isolate());
2804 2802
2805 bool done = false; 2803 bool done = false;
2806 for (; it->IsFound(); it->Next()) { 2804 for (; it->IsFound(); it->Next()) {
2807 switch (it->state()) { 2805 switch (it->state()) {
2808 case LookupIterator::NOT_FOUND: 2806 case LookupIterator::NOT_FOUND:
2809 case LookupIterator::UNKNOWN:
2810 UNREACHABLE(); 2807 UNREACHABLE();
2811 2808
2812 case LookupIterator::ACCESS_CHECK: 2809 case LookupIterator::ACCESS_CHECK:
2813 // TODO(verwaest): Remove the distinction. This is mostly bogus since we 2810 // TODO(verwaest): Remove the distinction. This is mostly bogus since we
2814 // don't know whether we'll want to fetch attributes or call a setter 2811 // don't know whether we'll want to fetch attributes or call a setter
2815 // until we find the property. 2812 // until we find the property.
2816 if (it->HasAccess(v8::ACCESS_SET)) break; 2813 if (it->HasAccess(v8::ACCESS_SET)) break;
2817 return JSObject::SetPropertyWithFailedAccessCheck(it, value, 2814 return JSObject::SetPropertyWithFailedAccessCheck(it, value,
2818 strict_mode); 2815 strict_mode);
2819 2816
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
3794 DCHECK(!value->IsTheHole()); 3791 DCHECK(!value->IsTheHole());
3795 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 3792 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
3796 bool is_observed = object->map()->is_observed() && 3793 bool is_observed = object->map()->is_observed() &&
3797 *name != it.isolate()->heap()->hidden_string(); 3794 *name != it.isolate()->heap()->hidden_string();
3798 for (; it.IsFound(); it.Next()) { 3795 for (; it.IsFound(); it.Next()) {
3799 switch (it.state()) { 3796 switch (it.state()) {
3800 case LookupIterator::INTERCEPTOR: 3797 case LookupIterator::INTERCEPTOR:
3801 case LookupIterator::JSPROXY: 3798 case LookupIterator::JSPROXY:
3802 case LookupIterator::NOT_FOUND: 3799 case LookupIterator::NOT_FOUND:
3803 case LookupIterator::TRANSITION: 3800 case LookupIterator::TRANSITION:
3804 case LookupIterator::UNKNOWN:
3805 UNREACHABLE(); 3801 UNREACHABLE();
3806 3802
3807 case LookupIterator::ACCESS_CHECK: 3803 case LookupIterator::ACCESS_CHECK:
3808 if (!it.isolate()->MayNamedAccess(object, name, v8::ACCESS_SET)) { 3804 if (!it.isolate()->MayNamedAccess(object, name, v8::ACCESS_SET)) {
3809 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); 3805 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY);
3810 } 3806 }
3811 break; 3807 break;
3812 3808
3813 case LookupIterator::ACCESSOR: { 3809 case LookupIterator::ACCESSOR: {
3814 PropertyDetails details = it.property_details(); 3810 PropertyDetails details = it.property_details();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3971 LookupIterator it(object, name, LookupIterator::HIDDEN); 3967 LookupIterator it(object, name, LookupIterator::HIDDEN);
3972 return GetPropertyAttributes(&it); 3968 return GetPropertyAttributes(&it);
3973 } 3969 }
3974 3970
3975 3971
3976 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( 3972 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
3977 LookupIterator* it) { 3973 LookupIterator* it) {
3978 for (; it->IsFound(); it->Next()) { 3974 for (; it->IsFound(); it->Next()) {
3979 switch (it->state()) { 3975 switch (it->state()) {
3980 case LookupIterator::NOT_FOUND: 3976 case LookupIterator::NOT_FOUND:
3981 case LookupIterator::UNKNOWN:
3982 case LookupIterator::TRANSITION: 3977 case LookupIterator::TRANSITION:
3983 UNREACHABLE(); 3978 UNREACHABLE();
3984 case LookupIterator::JSPROXY: 3979 case LookupIterator::JSPROXY:
3985 return JSProxy::GetPropertyAttributesWithHandler( 3980 return JSProxy::GetPropertyAttributesWithHandler(
3986 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name()); 3981 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name());
3987 case LookupIterator::INTERCEPTOR: { 3982 case LookupIterator::INTERCEPTOR: {
3988 Maybe<PropertyAttributes> result = 3983 Maybe<PropertyAttributes> result =
3989 JSObject::GetPropertyAttributesWithInterceptor( 3984 JSObject::GetPropertyAttributesWithInterceptor(
3990 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 3985 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
3991 if (!result.has_value) return result; 3986 if (!result.has_value) return result;
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
4911 4906
4912 bool is_observed = object->map()->is_observed() && 4907 bool is_observed = object->map()->is_observed() &&
4913 *name != it.isolate()->heap()->hidden_string(); 4908 *name != it.isolate()->heap()->hidden_string();
4914 Handle<Object> old_value = it.isolate()->factory()->the_hole_value(); 4909 Handle<Object> old_value = it.isolate()->factory()->the_hole_value();
4915 4910
4916 for (; it.IsFound(); it.Next()) { 4911 for (; it.IsFound(); it.Next()) {
4917 switch (it.state()) { 4912 switch (it.state()) {
4918 case LookupIterator::JSPROXY: 4913 case LookupIterator::JSPROXY:
4919 case LookupIterator::NOT_FOUND: 4914 case LookupIterator::NOT_FOUND:
4920 case LookupIterator::TRANSITION: 4915 case LookupIterator::TRANSITION:
4921 case LookupIterator::UNKNOWN:
4922 UNREACHABLE(); 4916 UNREACHABLE();
4923 case LookupIterator::ACCESS_CHECK: 4917 case LookupIterator::ACCESS_CHECK:
4924 if (it.HasAccess(v8::ACCESS_DELETE)) break; 4918 if (it.HasAccess(v8::ACCESS_DELETE)) break;
4925 it.isolate()->ReportFailedAccessCheck(it.GetHolder<JSObject>(), 4919 it.isolate()->ReportFailedAccessCheck(it.GetHolder<JSObject>(),
4926 v8::ACCESS_DELETE); 4920 v8::ACCESS_DELETE);
4927 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it.isolate(), Object); 4921 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it.isolate(), Object);
4928 return it.isolate()->factory()->false_value(); 4922 return it.isolate()->factory()->false_value();
4929 case LookupIterator::INTERCEPTOR: { 4923 case LookupIterator::INTERCEPTOR: {
4930 MaybeHandle<Object> maybe_result = 4924 MaybeHandle<Object> maybe_result =
4931 JSObject::DeletePropertyWithInterceptor(it.GetHolder<JSObject>(), 4925 JSObject::DeletePropertyWithInterceptor(it.GetHolder<JSObject>(),
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6290 } 6284 }
6291 } 6285 }
6292 } else { 6286 } else {
6293 LookupIterator it(object, name, 6287 LookupIterator it(object, name,
6294 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 6288 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
6295 for (; it.IsFound(); it.Next()) { 6289 for (; it.IsFound(); it.Next()) {
6296 switch (it.state()) { 6290 switch (it.state()) {
6297 case LookupIterator::INTERCEPTOR: 6291 case LookupIterator::INTERCEPTOR:
6298 case LookupIterator::NOT_FOUND: 6292 case LookupIterator::NOT_FOUND:
6299 case LookupIterator::TRANSITION: 6293 case LookupIterator::TRANSITION:
6300 case LookupIterator::UNKNOWN:
6301 UNREACHABLE(); 6294 UNREACHABLE();
6302 6295
6303 case LookupIterator::ACCESS_CHECK: 6296 case LookupIterator::ACCESS_CHECK:
6304 if (it.HasAccess(v8::ACCESS_HAS)) continue; 6297 if (it.HasAccess(v8::ACCESS_HAS)) continue;
6305 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>(), 6298 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>(),
6306 v8::ACCESS_HAS); 6299 v8::ACCESS_HAS);
6307 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 6300 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6308 return isolate->factory()->undefined_value(); 6301 return isolate->factory()->undefined_value();
6309 6302
6310 case LookupIterator::JSPROXY: 6303 case LookupIterator::JSPROXY:
(...skipping 10054 matching lines...) Expand 10 before | Expand all | Expand 10 after
16365 #define ERROR_MESSAGES_TEXTS(C, T) T, 16358 #define ERROR_MESSAGES_TEXTS(C, T) T,
16366 static const char* error_messages_[] = { 16359 static const char* error_messages_[] = {
16367 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16360 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16368 }; 16361 };
16369 #undef ERROR_MESSAGES_TEXTS 16362 #undef ERROR_MESSAGES_TEXTS
16370 return error_messages_[reason]; 16363 return error_messages_[reason];
16371 } 16364 }
16372 16365
16373 16366
16374 } } // namespace v8::internal 16367 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup-inl.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698