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

Side by Side Diff: src/objects.cc

Issue 1199493002: Revert relanded strong property access CL (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (js_object->map()->is_access_check_needed()) return false; 120 if (js_object->map()->is_access_check_needed()) return false;
121 auto isolate = js_object->GetIsolate(); 121 auto isolate = js_object->GetIsolate();
122 // TODO(dcarney): this should just be read from the symbol registry so as not 122 // TODO(dcarney): this should just be read from the symbol registry so as not
123 // to be context dependent. 123 // to be context dependent.
124 auto key = isolate->promise_status(); 124 auto key = isolate->promise_status();
125 // Shouldn't be possible to throw here. 125 // Shouldn't be possible to throw here.
126 return JSObject::HasRealNamedProperty(js_object, key).FromJust(); 126 return JSObject::HasRealNamedProperty(js_object, key).FromJust();
127 } 127 }
128 128
129 129
130 MaybeHandle<Object> Object::GetProperty(LookupIterator* it, 130 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
131 LanguageMode language_mode) {
132 for (; it->IsFound(); it->Next()) { 131 for (; it->IsFound(); it->Next()) {
133 switch (it->state()) { 132 switch (it->state()) {
134 case LookupIterator::NOT_FOUND: 133 case LookupIterator::NOT_FOUND:
135 case LookupIterator::TRANSITION: 134 case LookupIterator::TRANSITION:
136 UNREACHABLE(); 135 UNREACHABLE();
137 case LookupIterator::JSPROXY: 136 case LookupIterator::JSPROXY:
138 return JSProxy::GetPropertyWithHandler( 137 return JSProxy::GetPropertyWithHandler(
139 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName()); 138 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName());
140 case LookupIterator::INTERCEPTOR: { 139 case LookupIterator::INTERCEPTOR: {
141 bool done; 140 bool done;
142 Handle<Object> result; 141 Handle<Object> result;
143 ASSIGN_RETURN_ON_EXCEPTION( 142 ASSIGN_RETURN_ON_EXCEPTION(
144 it->isolate(), result, 143 it->isolate(), result,
145 JSObject::GetPropertyWithInterceptor(it, &done), Object); 144 JSObject::GetPropertyWithInterceptor(it, &done), Object);
146 if (done) return result; 145 if (done) return result;
147 break; 146 break;
148 } 147 }
149 case LookupIterator::ACCESS_CHECK: 148 case LookupIterator::ACCESS_CHECK:
150 if (it->HasAccess()) break; 149 if (it->HasAccess()) break;
151 return JSObject::GetPropertyWithFailedAccessCheck(it, language_mode); 150 return JSObject::GetPropertyWithFailedAccessCheck(it);
152 case LookupIterator::ACCESSOR: 151 case LookupIterator::ACCESSOR:
153 return GetPropertyWithAccessor(it, language_mode); 152 return GetPropertyWithAccessor(it);
154 case LookupIterator::INTEGER_INDEXED_EXOTIC: 153 case LookupIterator::INTEGER_INDEXED_EXOTIC:
155 return ReadAbsentProperty(it, language_mode); 154 return it->factory()->undefined_value();
156 case LookupIterator::DATA: 155 case LookupIterator::DATA:
157 return it->GetDataValue(); 156 return it->GetDataValue();
158 } 157 }
159 } 158 }
160 return ReadAbsentProperty(it, language_mode); 159 return it->factory()->undefined_value();
161 } 160 }
162 161
163 162
164 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object, 163 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
165 Handle<Name> name) { 164 Handle<Name> name) {
166 LookupIterator it(object, name, 165 LookupIterator it(object, name,
167 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 166 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
168 return GetDataProperty(&it); 167 return GetDataProperty(&it);
169 } 168 }
170 169
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 297
299 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 298 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
300 if (name->IsSymbol()) return isolate->factory()->undefined_value(); 299 if (name->IsSymbol()) return isolate->factory()->undefined_value();
301 300
302 Handle<Object> args[] = { receiver, name }; 301 Handle<Object> args[] = { receiver, name };
303 return CallTrap( 302 return CallTrap(
304 proxy, "get", isolate->derived_get_trap(), arraysize(args), args); 303 proxy, "get", isolate->derived_get_trap(), arraysize(args), args);
305 } 304 }
306 305
307 306
308 MaybeHandle<Object> Object::GetPropertyWithAccessor( 307 MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
309 LookupIterator* it, LanguageMode language_mode) {
310 Isolate* isolate = it->isolate(); 308 Isolate* isolate = it->isolate();
311 Handle<Object> structure = it->GetAccessors(); 309 Handle<Object> structure = it->GetAccessors();
312 Handle<Object> receiver = it->GetReceiver(); 310 Handle<Object> receiver = it->GetReceiver();
313 311
314 // We should never get here to initialize a const with the hole value since a 312 // We should never get here to initialize a const with the hole value since a
315 // const declaration would conflict with the getter. 313 // const declaration would conflict with the getter.
316 DCHECK(!structure->IsForeign()); 314 DCHECK(!structure->IsForeign());
317 315
318 // API style callbacks. 316 // API style callbacks.
319 if (structure->IsAccessorInfo()) { 317 if (structure->IsAccessorInfo()) {
(...skipping 11 matching lines...) Expand all
331 v8::AccessorNameGetterCallback call_fun = 329 v8::AccessorNameGetterCallback call_fun =
332 v8::ToCData<v8::AccessorNameGetterCallback>(info->getter()); 330 v8::ToCData<v8::AccessorNameGetterCallback>(info->getter());
333 if (call_fun == nullptr) return isolate->factory()->undefined_value(); 331 if (call_fun == nullptr) return isolate->factory()->undefined_value();
334 332
335 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name)); 333 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name));
336 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); 334 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder);
337 v8::Handle<v8::Value> result = 335 v8::Handle<v8::Value> result =
338 args.Call(call_fun, v8::Utils::ToLocal(name)); 336 args.Call(call_fun, v8::Utils::ToLocal(name));
339 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 337 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
340 if (result.IsEmpty()) { 338 if (result.IsEmpty()) {
341 return ReadAbsentProperty(isolate, receiver, name, language_mode); 339 return isolate->factory()->undefined_value();
342 } 340 }
343 Handle<Object> return_value = v8::Utils::OpenHandle(*result); 341 Handle<Object> return_value = v8::Utils::OpenHandle(*result);
344 return_value->VerifyApiCallResultType(); 342 return_value->VerifyApiCallResultType();
345 // Rebox handle before return. 343 // Rebox handle before return.
346 return handle(*return_value, isolate); 344 return handle(*return_value, isolate);
347 } 345 }
348 346
349 // Regular accessor. 347 // Regular accessor.
350 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); 348 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate);
351 if (getter->IsSpecFunction()) { 349 if (getter->IsSpecFunction()) {
352 // TODO(rossberg): nicer would be to cast to some JSCallable here... 350 // TODO(rossberg): nicer would be to cast to some JSCallable here...
353 return Object::GetPropertyWithDefinedGetter( 351 return Object::GetPropertyWithDefinedGetter(
354 receiver, Handle<JSReceiver>::cast(getter)); 352 receiver, Handle<JSReceiver>::cast(getter));
355 } 353 }
356 // Getter is not a function. 354 // Getter is not a function.
357 return ReadAbsentProperty(isolate, receiver, it->GetName(), language_mode); 355 return isolate->factory()->undefined_value();
358 } 356 }
359 357
360 358
361 bool AccessorInfo::IsCompatibleReceiverMap(Isolate* isolate, 359 bool AccessorInfo::IsCompatibleReceiverMap(Isolate* isolate,
362 Handle<AccessorInfo> info, 360 Handle<AccessorInfo> info,
363 Handle<Map> map) { 361 Handle<Map> map) {
364 if (!info->HasExpectedReceiverType()) return true; 362 if (!info->HasExpectedReceiverType()) return true;
365 if (!map->IsJSObjectMap()) return false; 363 if (!map->IsJSObjectMap()) return false;
366 return FunctionTemplateInfo::cast(info->expected_receiver_type()) 364 return FunctionTemplateInfo::cast(info->expected_receiver_type())
367 ->IsTemplateFor(*map); 365 ->IsTemplateFor(*map);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 481 }
484 } else if (it->state() == LookupIterator::INTERCEPTOR) { 482 } else if (it->state() == LookupIterator::INTERCEPTOR) {
485 if (it->GetInterceptor()->all_can_read()) return true; 483 if (it->GetInterceptor()->all_can_read()) return true;
486 } 484 }
487 } 485 }
488 return false; 486 return false;
489 } 487 }
490 488
491 489
492 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck( 490 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
493 LookupIterator* it, LanguageMode language_mode) { 491 LookupIterator* it) {
494 Handle<JSObject> checked = it->GetHolder<JSObject>(); 492 Handle<JSObject> checked = it->GetHolder<JSObject>();
495 while (FindAllCanReadHolder(it)) { 493 while (FindAllCanReadHolder(it)) {
496 if (it->state() == LookupIterator::ACCESSOR) { 494 if (it->state() == LookupIterator::ACCESSOR) {
497 return GetPropertyWithAccessor(it, language_mode); 495 return GetPropertyWithAccessor(it);
498 } 496 }
499 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 497 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
500 bool done; 498 bool done;
501 Handle<Object> result; 499 Handle<Object> result;
502 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), result, 500 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), result,
503 GetPropertyWithInterceptor(it, &done), Object); 501 GetPropertyWithInterceptor(it, &done), Object);
504 if (done) return result; 502 if (done) return result;
505 } 503 }
506 it->isolate()->ReportFailedAccessCheck(checked); 504 it->isolate()->ReportFailedAccessCheck(checked);
507 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); 505 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object);
(...skipping 2710 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 case LookupIterator::TRANSITION: 3216 case LookupIterator::TRANSITION:
3219 UNREACHABLE(); 3217 UNREACHABLE();
3220 } 3218 }
3221 } 3219 }
3222 3220
3223 return JSObject::AddDataProperty(&own_lookup, value, NONE, language_mode, 3221 return JSObject::AddDataProperty(&own_lookup, value, NONE, language_mode,
3224 store_mode); 3222 store_mode);
3225 } 3223 }
3226 3224
3227 3225
3228 MaybeHandle<Object> Object::ReadAbsentProperty(LookupIterator* it,
3229 LanguageMode language_mode) {
3230 return ReadAbsentProperty(it->isolate(), it->GetReceiver(), it->GetName(),
3231 language_mode);
3232 }
3233
3234 MaybeHandle<Object> Object::ReadAbsentProperty(Isolate* isolate,
3235 Handle<Object> receiver,
3236 Handle<Object> name,
3237 LanguageMode language_mode) {
3238 if (is_strong(language_mode)) {
3239 THROW_NEW_ERROR(
3240 isolate,
3241 NewTypeError(MessageTemplate::kStrongPropertyAccess, name, receiver),
3242 Object);
3243 }
3244 return isolate->factory()->undefined_value();
3245 }
3246
3247
3248 MaybeHandle<Object> Object::WriteToReadOnlyProperty( 3226 MaybeHandle<Object> Object::WriteToReadOnlyProperty(
3249 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { 3227 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) {
3250 return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(), 3228 return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(),
3251 it->GetName(), value, language_mode); 3229 it->GetName(), value, language_mode);
3252 } 3230 }
3253 3231
3254 3232
3255 MaybeHandle<Object> Object::WriteToReadOnlyProperty( 3233 MaybeHandle<Object> Object::WriteToReadOnlyProperty(
3256 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, 3234 Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
3257 Handle<Object> value, LanguageMode language_mode) { 3235 Handle<Object> value, LanguageMode language_mode) {
(...skipping 13442 matching lines...) Expand 10 before | Expand all | Expand 10 after
16700 Handle<Object> new_value) { 16678 Handle<Object> new_value) {
16701 if (cell->value() != *new_value) { 16679 if (cell->value() != *new_value) {
16702 cell->set_value(*new_value); 16680 cell->set_value(*new_value);
16703 Isolate* isolate = cell->GetIsolate(); 16681 Isolate* isolate = cell->GetIsolate();
16704 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16682 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16705 isolate, DependentCode::kPropertyCellChangedGroup); 16683 isolate, DependentCode::kPropertyCellChangedGroup);
16706 } 16684 }
16707 } 16685 }
16708 } // namespace internal 16686 } // namespace internal
16709 } // namespace v8 16687 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698