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

Side by Side Diff: src/objects.cc

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Force use of holder as receiver for non js accessor callbacks Created 6 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 | « 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 "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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } else { 122 } else {
123 result->isolate()->PushStackTraceAndDie( 123 result->isolate()->PushStackTraceAndDie(
124 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001); 124 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001);
125 } 125 }
126 } 126 }
127 ASSERT(holder != NULL); // Cannot handle null or undefined. 127 ASSERT(holder != NULL); // Cannot handle null or undefined.
128 JSReceiver::cast(holder)->Lookup(name, result); 128 JSReceiver::cast(holder)->Lookup(name, result);
129 } 129 }
130 130
131 131
132 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) { 132 MaybeHandle<Object> Object::GetPropertyHelper(
133 LookupIterator* it, bool force_holder_as_receiver_for_accessor_callback) {
133 for (; it->IsFound(); it->Next()) { 134 for (; it->IsFound(); it->Next()) {
134 switch (it->state()) { 135 switch (it->state()) {
135 case LookupIterator::NOT_FOUND: 136 case LookupIterator::NOT_FOUND:
136 UNREACHABLE(); 137 UNREACHABLE();
137 case LookupIterator::JSPROXY: 138 case LookupIterator::JSPROXY:
138 return JSProxy::GetPropertyWithHandler( 139 return JSProxy::GetPropertyWithHandler(
139 it->GetJSProxy(), it->GetReceiver(), it->name()); 140 it->GetJSProxy(), it->GetReceiver(), it->name());
140 case LookupIterator::INTERCEPTOR: { 141 case LookupIterator::INTERCEPTOR: {
141 MaybeHandle<Object> maybe_result = JSObject::GetPropertyWithInterceptor( 142 MaybeHandle<Object> maybe_result = JSObject::GetPropertyWithInterceptor(
142 it->GetHolder(), it->GetReceiver(), it->name()); 143 it->GetHolder(), it->GetReceiver(), it->name());
143 if (!maybe_result.is_null()) return maybe_result; 144 if (!maybe_result.is_null()) return maybe_result;
144 if (it->isolate()->has_pending_exception()) return maybe_result; 145 if (it->isolate()->has_pending_exception()) return maybe_result;
145 break; 146 break;
146 } 147 }
147 case LookupIterator::ACCESS_CHECK: 148 case LookupIterator::ACCESS_CHECK:
148 if (it->HasAccess(v8::ACCESS_GET)) break; 149 if (it->HasAccess(v8::ACCESS_GET)) break;
149 return JSObject::GetPropertyWithFailedAccessCheck(it); 150 return JSObject::GetPropertyWithFailedAccessCheck(it);
150 case LookupIterator::PROPERTY: 151 case LookupIterator::PROPERTY:
151 if (it->HasProperty()) { 152 if (it->HasProperty()) {
152 switch (it->property_kind()) { 153 switch (it->property_kind()) {
153 case LookupIterator::ACCESSOR: 154 case LookupIterator::ACCESSOR: {
154 return GetPropertyWithAccessor( 155 Handle<Object> accessors = it->GetAccessors();
155 it->GetReceiver(), it->name(), 156 Handle<Object> receiver;
156 it->GetHolder(), it->GetAccessors()); 157 if (force_holder_as_receiver_for_accessor_callback &&
158 !accessors->IsAccessorPair()) {
159 receiver = it->GetHolder();
160 } else {
161 receiver = it->GetReceiver();
162 }
163 return GetPropertyWithAccessor(receiver, it->name(),
164 it->GetHolder(), accessors);
165 }
Toon Verwaest 2014/07/23 12:08:38 Euh, no. What you want to do is fix a bug in Arra
157 case LookupIterator::DATA: 166 case LookupIterator::DATA:
158 return it->GetDataValue(); 167 return it->GetDataValue();
159 } 168 }
160 } 169 }
161 break; 170 break;
162 } 171 }
163 } 172 }
164 return it->factory()->undefined_value(); 173 return it->factory()->undefined_value();
165 } 174 }
166 175
167 176
177 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
178 return GetPropertyHelper(it, false);
179 }
180
181
182 MaybeHandle<Object> Object::GetPropertyForUnscopables(LookupIterator* it) {
183 // TODO(arv): For unscopables we need to make sure that we use the holder as
184 // the receiver for data properties that are implemented as callbacks
185 // (ACCESSER && !IsAccessorPair).
186 return GetPropertyHelper(it, true);
187 }
188
189
168 bool Object::ToInt32(int32_t* value) { 190 bool Object::ToInt32(int32_t* value) {
169 if (IsSmi()) { 191 if (IsSmi()) {
170 *value = Smi::cast(this)->value(); 192 *value = Smi::cast(this)->value();
171 return true; 193 return true;
172 } 194 }
173 if (IsHeapNumber()) { 195 if (IsHeapNumber()) {
174 double num = HeapNumber::cast(this)->value(); 196 double num = HeapNumber::cast(this)->value();
175 if (FastI2D(FastD2I(num)) == num) { 197 if (FastI2D(FastD2I(num)) == num) {
176 *value = FastD2I(num); 198 *value = FastD2I(num);
177 return true; 199 return true;
(...skipping 16760 matching lines...) Expand 10 before | Expand all | Expand 10 after
16938 #define ERROR_MESSAGES_TEXTS(C, T) T, 16960 #define ERROR_MESSAGES_TEXTS(C, T) T,
16939 static const char* error_messages_[] = { 16961 static const char* error_messages_[] = {
16940 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16962 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16941 }; 16963 };
16942 #undef ERROR_MESSAGES_TEXTS 16964 #undef ERROR_MESSAGES_TEXTS
16943 return error_messages_[reason]; 16965 return error_messages_[reason];
16944 } 16966 }
16945 16967
16946 16968
16947 } } // namespace v8::internal 16969 } } // 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