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

Side by Side Diff: src/objects.cc

Issue 231103002: Object::GetElements() and friends maybehandlification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: FixedArray::UnionOfKeys() maybehandlified Created 6 years, 8 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/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 // 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 return GetPrimitiveValue(data->primitive_value_descriptor, 374 return GetPrimitiveValue(data->primitive_value_descriptor,
375 current, 375 current,
376 isolate->heap()); 376 isolate->heap());
377 } 377 }
378 } 378 }
379 UNREACHABLE(); 379 UNREACHABLE();
380 return NULL; 380 return NULL;
381 } 381 }
382 382
383 383
384 static Handle<Object> GetDeclaredAccessorProperty(
385 Handle<Object> receiver,
386 Handle<DeclaredAccessorInfo> info,
387 Isolate* isolate) {
388 CALL_HEAP_FUNCTION(isolate,
389 GetDeclaredAccessorProperty(*receiver, *info, isolate),
390 Object);
391 }
392
393
384 Handle<FixedArray> JSObject::EnsureWritableFastElements( 394 Handle<FixedArray> JSObject::EnsureWritableFastElements(
385 Handle<JSObject> object) { 395 Handle<JSObject> object) {
386 CALL_HEAP_FUNCTION(object->GetIsolate(), 396 CALL_HEAP_FUNCTION(object->GetIsolate(),
387 object->EnsureWritableFastElements(), 397 object->EnsureWritableFastElements(),
388 FixedArray); 398 FixedArray);
389 } 399 }
390 400
391 401
392 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object, 402 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
393 Handle<Object> receiver, 403 Handle<Object> receiver,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 isolate), 438 isolate),
429 Object); 439 Object);
430 } 440 }
431 441
432 Handle<ExecutableAccessorInfo> data = 442 Handle<ExecutableAccessorInfo> data =
433 Handle<ExecutableAccessorInfo>::cast(structure); 443 Handle<ExecutableAccessorInfo>::cast(structure);
434 v8::AccessorGetterCallback call_fun = 444 v8::AccessorGetterCallback call_fun =
435 v8::ToCData<v8::AccessorGetterCallback>(data->getter()); 445 v8::ToCData<v8::AccessorGetterCallback>(data->getter());
436 if (call_fun == NULL) return isolate->factory()->undefined_value(); 446 if (call_fun == NULL) return isolate->factory()->undefined_value();
437 447
438 HandleScope scope(isolate);
439 Handle<JSObject> self = Handle<JSObject>::cast(receiver); 448 Handle<JSObject> self = Handle<JSObject>::cast(receiver);
440 Handle<String> key = Handle<String>::cast(name); 449 Handle<String> key = Handle<String>::cast(name);
441 LOG(isolate, ApiNamedPropertyAccess("load", *self, *name)); 450 LOG(isolate, ApiNamedPropertyAccess("load", *self, *name));
442 PropertyCallbackArguments args(isolate, data->data(), *self, *object); 451 PropertyCallbackArguments args(isolate, data->data(), *self, *object);
443 v8::Handle<v8::Value> result = 452 v8::Handle<v8::Value> result =
444 args.Call(call_fun, v8::Utils::ToLocal(key)); 453 args.Call(call_fun, v8::Utils::ToLocal(key));
445 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 454 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
446 if (result.IsEmpty()) { 455 if (result.IsEmpty()) {
447 return isolate->factory()->undefined_value(); 456 return isolate->factory()->undefined_value();
448 } 457 }
449 Handle<Object> return_value = v8::Utils::OpenHandle(*result); 458 Handle<Object> return_value = v8::Utils::OpenHandle(*result);
450 return_value->VerifyApiCallResultType(); 459 return_value->VerifyApiCallResultType();
451 return scope.CloseAndEscape(return_value); 460 // Rebox handle before return.
461 return handle(*return_value, isolate);
452 } 462 }
453 463
454 // __defineGetter__ callback 464 // __defineGetter__ callback
455 Handle<Object> getter(Handle<AccessorPair>::cast(structure)->getter(), 465 Handle<Object> getter(Handle<AccessorPair>::cast(structure)->getter(),
456 isolate); 466 isolate);
457 if (getter->IsSpecFunction()) { 467 if (getter->IsSpecFunction()) {
458 // TODO(rossberg): nicer would be to cast to some JSCallable here... 468 // TODO(rossberg): nicer would be to cast to some JSCallable here...
459 CALL_HEAP_FUNCTION( 469 return Object::GetPropertyWithDefinedGetter(
460 isolate, 470 object, receiver, Handle<JSReceiver>::cast(getter));
461 object->GetPropertyWithDefinedGetter(*receiver,
462 JSReceiver::cast(*getter)),
463 Object);
464 } 471 }
465 // Getter is not a function. 472 // Getter is not a function.
466 return isolate->factory()->undefined_value(); 473 return isolate->factory()->undefined_value();
467 } 474 }
468 475
469 476
470 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw, 477 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw,
471 Name* name_raw) { 478 Name* name_raw) {
472 Isolate* isolate = GetIsolate(); 479 Isolate* isolate = GetIsolate();
473 HandleScope scope(isolate); 480 HandleScope scope(isolate);
474 Handle<Object> receiver(receiver_raw, isolate); 481 Handle<Object> receiver(receiver_raw, isolate);
475 Handle<Object> name(name_raw, isolate); 482 Handle<Object> name(name_raw, isolate);
476 483
477 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 484 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
478 if (name->IsSymbol()) return isolate->heap()->undefined_value(); 485 if (name->IsSymbol()) return isolate->heap()->undefined_value();
479 486
480 Handle<Object> args[] = { receiver, name }; 487 Handle<Object> args[] = { receiver, name };
481 Handle<Object> result; 488 Handle<Object> result;
482 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 489 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
483 isolate, result, 490 isolate, result,
484 CallTrap(handle(this), 491 CallTrap(handle(this),
485 "get", 492 "get",
486 isolate->derived_get_trap(), 493 isolate->derived_get_trap(),
487 ARRAY_SIZE(args), 494 ARRAY_SIZE(args),
488 args)); 495 args));
489 return *result; 496 return *result;
490 } 497 }
491 498
492 499
493 Handle<Object> Object::GetPropertyOrElement(Handle<Object> object, 500 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
494 Handle<Name> name) { 501 Handle<Name> name) {
495 uint32_t index; 502 uint32_t index;
496 Isolate* isolate = name->GetIsolate(); 503 Isolate* isolate = name->GetIsolate();
497 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index); 504 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index);
498 return GetProperty(object, name); 505 return GetProperty(object, name);
499 } 506 }
500 507
501 508
502 Handle<Object> Object::GetProperty(Handle<Object> object, 509 Handle<Object> Object::GetProperty(Handle<Object> object,
503 Handle<Name> name) { 510 Handle<Name> name) {
504 CALL_HEAP_FUNCTION(name->GetIsolate(), object->GetProperty(*name), Object); 511 CALL_HEAP_FUNCTION(name->GetIsolate(), object->GetProperty(*name), Object);
(...skipping 21 matching lines...) Expand all
526 } 533 }
527 534
528 535
529 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) { 536 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) {
530 Isolate* isolate = proxy->GetIsolate(); 537 Isolate* isolate = proxy->GetIsolate();
531 Handle<String> name = isolate->factory()->Uint32ToString(index); 538 Handle<String> name = isolate->factory()->Uint32ToString(index);
532 return HasPropertyWithHandler(proxy, name); 539 return HasPropertyWithHandler(proxy, name);
533 } 540 }
534 541
535 542
536 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, 543 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter(
537 JSReceiver* getter) { 544 Handle<Object> object,
545 Handle<Object> receiver,
546 Handle<JSReceiver> getter) {
538 Isolate* isolate = getter->GetIsolate(); 547 Isolate* isolate = getter->GetIsolate();
539 HandleScope scope(isolate);
540 Handle<JSReceiver> fun(getter);
541 Handle<Object> self(receiver, isolate);
542 #ifdef ENABLE_DEBUGGER_SUPPORT 548 #ifdef ENABLE_DEBUGGER_SUPPORT
543 Debug* debug = isolate->debug(); 549 Debug* debug = isolate->debug();
544 // Handle stepping into a getter if step into is active. 550 // Handle stepping into a getter if step into is active.
545 // TODO(rossberg): should this apply to getters that are function proxies? 551 // TODO(rossberg): should this apply to getters that are function proxies?
546 if (debug->StepInActive() && fun->IsJSFunction()) { 552 if (debug->StepInActive() && getter->IsJSFunction()) {
547 debug->HandleStepIn( 553 debug->HandleStepIn(
548 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false); 554 Handle<JSFunction>::cast(getter), Handle<Object>::null(), 0, false);
549 } 555 }
550 #endif 556 #endif
551 557
552 bool has_pending_exception; 558 bool has_pending_exception;
553 Handle<Object> result = Execution::Call( 559 Handle<Object> result = Execution::Call(
554 isolate, fun, self, 0, NULL, &has_pending_exception, true); 560 isolate, getter, receiver, 0, NULL, &has_pending_exception, true);
555 // Check for pending exception and return the result. 561 // Check for pending exception and return the result.
556 if (has_pending_exception) return Failure::Exception(); 562 if (has_pending_exception) return MaybeHandle<Object>();
557 return *result; 563 return result;
558 } 564 }
559 565
560 566
561 // Only deal with CALLBACKS and INTERCEPTOR 567 // Only deal with CALLBACKS and INTERCEPTOR
562 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck( 568 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
563 Handle<JSObject> object, 569 Handle<JSObject> object,
564 Handle<Object> receiver, 570 Handle<Object> receiver,
565 LookupResult* result, 571 LookupResult* result,
566 Handle<Name> name, 572 Handle<Name> name,
567 PropertyAttributes* attributes) { 573 PropertyAttributes* attributes) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 } 960 }
955 case NONEXISTENT: 961 case NONEXISTENT:
956 UNREACHABLE(); 962 UNREACHABLE();
957 break; 963 break;
958 } 964 }
959 UNREACHABLE(); 965 UNREACHABLE();
960 return NULL; 966 return NULL;
961 } 967 }
962 968
963 969
964 Handle<Object> Object::GetElementWithReceiver(Isolate* isolate, 970 MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate,
965 Handle<Object> object, 971 Handle<Object> object,
966 Handle<Object> receiver, 972 Handle<Object> receiver,
967 uint32_t index) { 973 uint32_t index) {
968 Handle<Object> holder; 974 Handle<Object> holder;
969 975
970 // Iterate up the prototype chain until an element is found or the null 976 // Iterate up the prototype chain until an element is found or the null
971 // prototype is encountered. 977 // prototype is encountered.
972 for (holder = object; 978 for (holder = object;
973 !holder->IsNull(); 979 !holder->IsNull();
974 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) { 980 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) {
975 if (!holder->IsJSObject()) { 981 if (!holder->IsJSObject()) {
976 Context* native_context = isolate->context()->native_context(); 982 Context* native_context = isolate->context()->native_context();
977 if (holder->IsNumber()) { 983 if (holder->IsNumber()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1016 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
1011 return isolate->factory()->undefined_value(); 1017 return isolate->factory()->undefined_value();
1012 } 1018 }
1013 } 1019 }
1014 1020
1015 if (js_object->HasIndexedInterceptor()) { 1021 if (js_object->HasIndexedInterceptor()) {
1016 return JSObject::GetElementWithInterceptor(js_object, receiver, index); 1022 return JSObject::GetElementWithInterceptor(js_object, receiver, index);
1017 } 1023 }
1018 1024
1019 if (js_object->elements() != isolate->heap()->empty_fixed_array()) { 1025 if (js_object->elements() != isolate->heap()->empty_fixed_array()) {
1020 Handle<Object> result = js_object->GetElementsAccessor()->Get( 1026 Handle<Object> result;
1021 receiver, js_object, index); 1027 ASSIGN_RETURN_ON_EXCEPTION(
1022 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); 1028 isolate, result,
1029 js_object->GetElementsAccessor()->Get(receiver, js_object, index),
1030 Object);
1023 if (!result->IsTheHole()) return result; 1031 if (!result->IsTheHole()) return result;
1024 } 1032 }
1025 } 1033 }
1026 1034
1027 return isolate->factory()->undefined_value(); 1035 return isolate->factory()->undefined_value();
1028 } 1036 }
1029 1037
1030 1038
1031 Object* Object::GetPrototype(Isolate* isolate) { 1039 Object* Object::GetPrototype(Isolate* isolate) {
1032 if (IsSmi()) { 1040 if (IsSmi()) {
(...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 3878
3871 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy, 3879 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy,
3872 const char* name, 3880 const char* name,
3873 Handle<Object> derived, 3881 Handle<Object> derived,
3874 int argc, 3882 int argc,
3875 Handle<Object> argv[]) { 3883 Handle<Object> argv[]) {
3876 Isolate* isolate = proxy->GetIsolate(); 3884 Isolate* isolate = proxy->GetIsolate();
3877 Handle<Object> handler(proxy->handler(), isolate); 3885 Handle<Object> handler(proxy->handler(), isolate);
3878 3886
3879 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name); 3887 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name);
3880 Handle<Object> trap = Object::GetPropertyOrElement(handler, trap_name); 3888 Handle<Object> trap;
3881 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, trap, MaybeHandle<Object>()); 3889 ASSIGN_RETURN_ON_EXCEPTION(
3890 isolate, trap,
3891 Object::GetPropertyOrElement(handler, trap_name),
3892 Object);
3882 3893
3883 if (trap->IsUndefined()) { 3894 if (trap->IsUndefined()) {
3884 if (derived.is_null()) { 3895 if (derived.is_null()) {
3885 Handle<Object> args[] = { handler, trap_name }; 3896 Handle<Object> args[] = { handler, trap_name };
3886 Handle<Object> error = isolate->factory()->NewTypeError( 3897 Handle<Object> error = isolate->factory()->NewTypeError(
3887 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); 3898 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
3888 return isolate->Throw<Object>(error); 3899 return isolate->Throw<Object>(error);
3889 } 3900 }
3890 trap = Handle<Object>(derived); 3901 trap = Handle<Object>(derived);
3891 } 3902 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 return isolate->Throw<Object>(error); 4145 return isolate->Throw<Object>(error);
4135 } else { 4146 } else {
4136 return value; 4147 return value;
4137 } 4148 }
4138 } 4149 }
4139 4150
4140 Handle<Object> old_value = isolate->factory()->the_hole_value(); 4151 Handle<Object> old_value = isolate->factory()->the_hole_value();
4141 bool is_observed = object->map()->is_observed() && 4152 bool is_observed = object->map()->is_observed() &&
4142 *name != isolate->heap()->hidden_string(); 4153 *name != isolate->heap()->hidden_string();
4143 if (is_observed && lookup->IsDataProperty()) { 4154 if (is_observed && lookup->IsDataProperty()) {
4144 old_value = Object::GetPropertyOrElement(object, name); 4155 old_value = Object::GetPropertyOrElement(object, name).ToHandleChecked();
4145 CHECK_NOT_EMPTY_HANDLE(isolate, old_value);
4146 } 4156 }
4147 4157
4148 // This is a real property that is not read-only, or it is a 4158 // This is a real property that is not read-only, or it is a
4149 // transition or null descriptor and there are no setters in the prototypes. 4159 // transition or null descriptor and there are no setters in the prototypes.
4150 MaybeHandle<Object> maybe_result = value; 4160 MaybeHandle<Object> maybe_result = value;
4151 if (lookup->IsTransition()) { 4161 if (lookup->IsTransition()) {
4152 maybe_result = SetPropertyUsingTransition(handle(lookup->holder()), lookup, 4162 maybe_result = SetPropertyUsingTransition(handle(lookup->holder()), lookup,
4153 name, value, attributes); 4163 name, value, attributes);
4154 } else { 4164 } else {
4155 switch (lookup->type()) { 4165 switch (lookup->type()) {
(...skipping 26 matching lines...) Expand all
4182 Handle<Object> result; 4192 Handle<Object> result;
4183 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); 4193 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
4184 4194
4185 if (is_observed) { 4195 if (is_observed) {
4186 if (lookup->IsTransition()) { 4196 if (lookup->IsTransition()) {
4187 EnqueueChangeRecord(object, "add", name, old_value); 4197 EnqueueChangeRecord(object, "add", name, old_value);
4188 } else { 4198 } else {
4189 LookupResult new_lookup(isolate); 4199 LookupResult new_lookup(isolate);
4190 object->LocalLookup(*name, &new_lookup, true); 4200 object->LocalLookup(*name, &new_lookup, true);
4191 if (new_lookup.IsDataProperty()) { 4201 if (new_lookup.IsDataProperty()) {
4192 Handle<Object> new_value = Object::GetPropertyOrElement(object, name); 4202 Handle<Object> new_value =
4193 CHECK_NOT_EMPTY_HANDLE(isolate, new_value); 4203 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4194 if (!new_value->SameValue(*old_value)) { 4204 if (!new_value->SameValue(*old_value)) {
4195 EnqueueChangeRecord(object, "update", name, old_value); 4205 EnqueueChangeRecord(object, "update", name, old_value);
4196 } 4206 }
4197 } 4207 }
4198 } 4208 }
4199 } 4209 }
4200 4210
4201 return result; 4211 return result;
4202 } 4212 }
4203 4213
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4261 return AddProperty(object, name, value, attributes, SLOPPY, 4271 return AddProperty(object, name, value, attributes, SLOPPY,
4262 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode, flag); 4272 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode, flag);
4263 } 4273 }
4264 4274
4265 Handle<Object> old_value = isolate->factory()->the_hole_value(); 4275 Handle<Object> old_value = isolate->factory()->the_hole_value();
4266 PropertyAttributes old_attributes = ABSENT; 4276 PropertyAttributes old_attributes = ABSENT;
4267 bool is_observed = object->map()->is_observed() && 4277 bool is_observed = object->map()->is_observed() &&
4268 *name != isolate->heap()->hidden_string(); 4278 *name != isolate->heap()->hidden_string();
4269 if (is_observed && lookup.IsProperty()) { 4279 if (is_observed && lookup.IsProperty()) {
4270 if (lookup.IsDataProperty()) { 4280 if (lookup.IsDataProperty()) {
4271 old_value = Object::GetPropertyOrElement(object, name); 4281 old_value = Object::GetPropertyOrElement(object, name).ToHandleChecked();
4272 CHECK_NOT_EMPTY_HANDLE(isolate, old_value);
4273 } 4282 }
4274 old_attributes = lookup.GetAttributes(); 4283 old_attributes = lookup.GetAttributes();
4275 } 4284 }
4276 4285
4277 // Check of IsReadOnly removed from here in clone. 4286 // Check of IsReadOnly removed from here in clone.
4278 if (lookup.IsTransition()) { 4287 if (lookup.IsTransition()) {
4279 Handle<Object> result; 4288 Handle<Object> result;
4280 ASSIGN_RETURN_ON_EXCEPTION( 4289 ASSIGN_RETURN_ON_EXCEPTION(
4281 isolate, result, 4290 isolate, result,
4282 SetPropertyUsingTransition( 4291 SetPropertyUsingTransition(
(...skipping 27 matching lines...) Expand all
4310 if (is_observed) { 4319 if (is_observed) {
4311 if (lookup.IsTransition()) { 4320 if (lookup.IsTransition()) {
4312 EnqueueChangeRecord(object, "add", name, old_value); 4321 EnqueueChangeRecord(object, "add", name, old_value);
4313 } else if (old_value->IsTheHole()) { 4322 } else if (old_value->IsTheHole()) {
4314 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4323 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4315 } else { 4324 } else {
4316 LookupResult new_lookup(isolate); 4325 LookupResult new_lookup(isolate);
4317 object->LocalLookup(*name, &new_lookup, true); 4326 object->LocalLookup(*name, &new_lookup, true);
4318 bool value_changed = false; 4327 bool value_changed = false;
4319 if (new_lookup.IsDataProperty()) { 4328 if (new_lookup.IsDataProperty()) {
4320 Handle<Object> new_value = Object::GetPropertyOrElement(object, name); 4329 Handle<Object> new_value =
4321 CHECK_NOT_EMPTY_HANDLE(isolate, new_value); 4330 Object::GetPropertyOrElement(object, name).ToHandleChecked();
4322 value_changed = !old_value->SameValue(*new_value); 4331 value_changed = !old_value->SameValue(*new_value);
4323 } 4332 }
4324 if (new_lookup.GetAttributes() != old_attributes) { 4333 if (new_lookup.GetAttributes() != old_attributes) {
4325 if (!value_changed) old_value = isolate->factory()->the_hole_value(); 4334 if (!value_changed) old_value = isolate->factory()->the_hole_value();
4326 EnqueueChangeRecord(object, "reconfigure", name, old_value); 4335 EnqueueChangeRecord(object, "reconfigure", name, old_value);
4327 } else if (value_changed) { 4336 } else if (value_changed) {
4328 EnqueueChangeRecord(object, "update", name, old_value); 4337 EnqueueChangeRecord(object, "update", name, old_value);
4329 } 4338 }
4330 } 4339 }
4331 } 4340 }
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
5330 isolate->Throw(*error); 5339 isolate->Throw(*error);
5331 return Handle<Object>(); 5340 return Handle<Object>();
5332 } 5341 }
5333 return isolate->factory()->false_value(); 5342 return isolate->factory()->false_value();
5334 } 5343 }
5335 5344
5336 Handle<Object> old_value = isolate->factory()->the_hole_value(); 5345 Handle<Object> old_value = isolate->factory()->the_hole_value();
5337 bool is_observed = object->map()->is_observed() && 5346 bool is_observed = object->map()->is_observed() &&
5338 *name != isolate->heap()->hidden_string(); 5347 *name != isolate->heap()->hidden_string();
5339 if (is_observed && lookup.IsDataProperty()) { 5348 if (is_observed && lookup.IsDataProperty()) {
5340 old_value = Object::GetPropertyOrElement(object, name); 5349 old_value = Object::GetPropertyOrElement(object, name).ToHandleChecked();
5341 CHECK_NOT_EMPTY_HANDLE(isolate, old_value);
5342 } 5350 }
5343 Handle<Object> result; 5351 Handle<Object> result;
5344 5352
5345 // Check for interceptor. 5353 // Check for interceptor.
5346 if (lookup.IsInterceptor()) { 5354 if (lookup.IsInterceptor()) {
5347 // Skip interceptor if forcing a deletion. 5355 // Skip interceptor if forcing a deletion.
5348 if (mode == FORCE_DELETION) { 5356 if (mode == FORCE_DELETION) {
5349 result = DeletePropertyPostInterceptor(object, name, mode); 5357 result = DeletePropertyPostInterceptor(object, name, mode);
5350 } else { 5358 } else {
5351 result = DeletePropertyWithInterceptor(object, name); 5359 result = DeletePropertyWithInterceptor(object, name);
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
6443 if (is_element) { 6451 if (is_element) {
6444 preexists = HasLocalElement(object, index); 6452 preexists = HasLocalElement(object, index);
6445 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) { 6453 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) {
6446 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); 6454 old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
6447 } 6455 }
6448 } else { 6456 } else {
6449 LookupResult lookup(isolate); 6457 LookupResult lookup(isolate);
6450 object->LocalLookup(*name, &lookup, true); 6458 object->LocalLookup(*name, &lookup, true);
6451 preexists = lookup.IsProperty(); 6459 preexists = lookup.IsProperty();
6452 if (preexists && lookup.IsDataProperty()) { 6460 if (preexists && lookup.IsDataProperty()) {
6453 old_value = Object::GetPropertyOrElement(object, name); 6461 old_value =
6454 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); 6462 Object::GetPropertyOrElement(object, name).ToHandleChecked();
6455 } 6463 }
6456 } 6464 }
6457 } 6465 }
6458 6466
6459 if (is_element) { 6467 if (is_element) {
6460 DefineElementAccessor( 6468 DefineElementAccessor(
6461 object, index, getter, setter, attributes, access_control); 6469 object, index, getter, setter, attributes, access_control);
6462 } else { 6470 } else {
6463 DefinePropertyAccessor( 6471 DefinePropertyAccessor(
6464 object, name, getter, setter, attributes, access_control); 6472 object, name, getter, setter, attributes, access_control);
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
7943 7951
7944 void FixedArray::Shrink(int new_length) { 7952 void FixedArray::Shrink(int new_length) {
7945 ASSERT(0 <= new_length && new_length <= length()); 7953 ASSERT(0 <= new_length && new_length <= length());
7946 if (new_length < length()) { 7954 if (new_length < length()) {
7947 RightTrimFixedArray<Heap::FROM_MUTATOR>( 7955 RightTrimFixedArray<Heap::FROM_MUTATOR>(
7948 GetHeap(), this, length() - new_length); 7956 GetHeap(), this, length() - new_length);
7949 } 7957 }
7950 } 7958 }
7951 7959
7952 7960
7953 Handle<FixedArray> FixedArray::AddKeysFromJSArray(Handle<FixedArray> content, 7961 MaybeHandle<FixedArray> FixedArray::AddKeysFromJSArray(
7954 Handle<JSArray> array) { 7962 Handle<FixedArray> content,
7963 Handle<JSArray> array) {
7955 ElementsAccessor* accessor = array->GetElementsAccessor(); 7964 ElementsAccessor* accessor = array->GetElementsAccessor();
7956 Handle<FixedArray> result = 7965 Handle<FixedArray> result;
7957 accessor->AddElementsToFixedArray(array, array, content); 7966 ASSIGN_RETURN_ON_EXCEPTION(
7967 array->GetIsolate(), result,
7968 accessor->AddElementsToFixedArray(array, array, content),
7969 FixedArray);
7958 7970
7959 #ifdef ENABLE_SLOW_ASSERTS 7971 #ifdef ENABLE_SLOW_ASSERTS
7960 if (FLAG_enable_slow_asserts) { 7972 if (FLAG_enable_slow_asserts) {
7961 DisallowHeapAllocation no_allocation; 7973 DisallowHeapAllocation no_allocation;
7962 for (int i = 0; i < result->length(); i++) { 7974 for (int i = 0; i < result->length(); i++) {
7963 Object* current = result->get(i); 7975 Object* current = result->get(i);
7964 ASSERT(current->IsNumber() || current->IsName()); 7976 ASSERT(current->IsNumber() || current->IsName());
7965 } 7977 }
7966 } 7978 }
7967 #endif 7979 #endif
7968 return result; 7980 return result;
7969 } 7981 }
7970 7982
7971 7983
7972 Handle<FixedArray> FixedArray::UnionOfKeys(Handle<FixedArray> first, 7984 MaybeHandle<FixedArray> FixedArray::UnionOfKeys(Handle<FixedArray> first,
7973 Handle<FixedArray> second) { 7985 Handle<FixedArray> second) {
7974 ElementsAccessor* accessor = ElementsAccessor::ForArray(second); 7986 ElementsAccessor* accessor = ElementsAccessor::ForArray(second);
7975 Handle<FixedArray> result = 7987 Handle<FixedArray> result;
7988 ASSIGN_RETURN_ON_EXCEPTION(
7989 first->GetIsolate(), result,
7976 accessor->AddElementsToFixedArray( 7990 accessor->AddElementsToFixedArray(
7977 Handle<Object>::null(), // receiver 7991 Handle<Object>::null(), // receiver
7978 Handle<JSObject>::null(), // holder 7992 Handle<JSObject>::null(), // holder
7979 first, 7993 first,
7980 Handle<FixedArrayBase>::cast(second)); 7994 Handle<FixedArrayBase>::cast(second)),
7995 FixedArray);
7981 7996
7982 #ifdef ENABLE_SLOW_ASSERTS 7997 #ifdef ENABLE_SLOW_ASSERTS
7983 if (FLAG_enable_slow_asserts) { 7998 if (FLAG_enable_slow_asserts) {
7984 DisallowHeapAllocation no_allocation; 7999 DisallowHeapAllocation no_allocation;
7985 for (int i = 0; i < result->length(); i++) { 8000 for (int i = 0; i < result->length(); i++) {
7986 Object* current = result->get(i); 8001 Object* current = result->get(i);
7987 ASSERT(current->IsNumber() || current->IsName()); 8002 ASSERT(current->IsNumber() || current->IsName());
7988 } 8003 }
7989 } 8004 }
7990 #endif 8005 #endif
(...skipping 3970 matching lines...) Expand 10 before | Expand all | Expand 10 after
11961 if (!result.IsEmpty()) return value; 11976 if (!result.IsEmpty()) return value;
11962 } 11977 }
11963 11978
11964 return SetElementWithoutInterceptor(object, index, value, attributes, 11979 return SetElementWithoutInterceptor(object, index, value, attributes,
11965 strict_mode, 11980 strict_mode,
11966 check_prototype, 11981 check_prototype,
11967 set_mode); 11982 set_mode);
11968 } 11983 }
11969 11984
11970 11985
11971 // TODO(ishell): Temporary wrapper until handlified. 11986 MaybeHandle<Object> JSObject::GetElementWithCallback(
11972 Handle<Object> JSObject::GetElementWithCallback(
11973 Handle<JSObject> object, 11987 Handle<JSObject> object,
11974 Handle<Object> receiver, 11988 Handle<Object> receiver,
11975 Handle<Object> structure, 11989 Handle<Object> structure,
11976 uint32_t index, 11990 uint32_t index,
11977 Handle<Object> holder) { 11991 Handle<Object> holder) {
11978 CALL_HEAP_FUNCTION(object->GetIsolate(), 11992 Isolate* isolate = object->GetIsolate();
11979 object->GetElementWithCallback(
11980 *receiver, *structure, index, *holder),
11981 Object);
11982 }
11983
11984
11985 MaybeObject* JSObject::GetElementWithCallback(Object* receiver,
11986 Object* structure,
11987 uint32_t index,
11988 Object* holder) {
11989 Isolate* isolate = GetIsolate();
11990 ASSERT(!structure->IsForeign()); 11993 ASSERT(!structure->IsForeign());
11991 11994
11992 // api style callbacks. 11995 // api style callbacks.
11993 if (structure->IsExecutableAccessorInfo()) { 11996 if (structure->IsExecutableAccessorInfo()) {
11994 Handle<ExecutableAccessorInfo> data( 11997 Handle<ExecutableAccessorInfo> data =
11995 ExecutableAccessorInfo::cast(structure)); 11998 Handle<ExecutableAccessorInfo>::cast(structure);
11996 Object* fun_obj = data->getter(); 11999 Object* fun_obj = data->getter();
11997 v8::AccessorGetterCallback call_fun = 12000 v8::AccessorGetterCallback call_fun =
11998 v8::ToCData<v8::AccessorGetterCallback>(fun_obj); 12001 v8::ToCData<v8::AccessorGetterCallback>(fun_obj);
11999 if (call_fun == NULL) return isolate->heap()->undefined_value(); 12002 if (call_fun == NULL) return isolate->factory()->undefined_value();
12000 HandleScope scope(isolate); 12003 Handle<JSObject> self = Handle<JSObject>::cast(receiver);
12001 Handle<JSObject> self(JSObject::cast(receiver)); 12004 Handle<JSObject> holder_handle = Handle<JSObject>::cast(holder);
12002 Handle<JSObject> holder_handle(JSObject::cast(holder));
12003 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 12005 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12004 Handle<String> key = isolate->factory()->NumberToString(number); 12006 Handle<String> key = isolate->factory()->NumberToString(number);
12005 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); 12007 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key));
12006 PropertyCallbackArguments 12008 PropertyCallbackArguments
12007 args(isolate, data->data(), *self, *holder_handle); 12009 args(isolate, data->data(), *self, *holder_handle);
12008 v8::Handle<v8::Value> result = args.Call(call_fun, v8::Utils::ToLocal(key)); 12010 v8::Handle<v8::Value> result = args.Call(call_fun, v8::Utils::ToLocal(key));
12009 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 12011 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
12010 if (result.IsEmpty()) return isolate->heap()->undefined_value(); 12012 if (result.IsEmpty()) return isolate->factory()->undefined_value();
12011 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 12013 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
12012 result_internal->VerifyApiCallResultType(); 12014 result_internal->VerifyApiCallResultType();
12013 return *result_internal; 12015 // Rebox handle before return.
12016 return handle(*result_internal, isolate);
12014 } 12017 }
12015 12018
12016 // __defineGetter__ callback 12019 // __defineGetter__ callback
12017 if (structure->IsAccessorPair()) { 12020 if (structure->IsAccessorPair()) {
12018 Object* getter = AccessorPair::cast(structure)->getter(); 12021 Handle<Object> getter(Handle<AccessorPair>::cast(structure)->getter(),
12022 isolate);
12019 if (getter->IsSpecFunction()) { 12023 if (getter->IsSpecFunction()) {
12020 // TODO(rossberg): nicer would be to cast to some JSCallable here... 12024 // TODO(rossberg): nicer would be to cast to some JSCallable here...
12021 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); 12025 return GetPropertyWithDefinedGetter(
12026 object, receiver, Handle<JSReceiver>::cast(getter));
12022 } 12027 }
12023 // Getter is not a function. 12028 // Getter is not a function.
12024 return isolate->heap()->undefined_value(); 12029 return isolate->factory()->undefined_value();
12025 } 12030 }
12026 12031
12027 if (structure->IsDeclaredAccessorInfo()) { 12032 if (structure->IsDeclaredAccessorInfo()) {
12028 return GetDeclaredAccessorProperty(receiver, 12033 return GetDeclaredAccessorProperty(
12029 DeclaredAccessorInfo::cast(structure), 12034 receiver, Handle<DeclaredAccessorInfo>::cast(structure), isolate);
12030 isolate);
12031 } 12035 }
12032 12036
12033 UNREACHABLE(); 12037 UNREACHABLE();
12034 return NULL; 12038 return MaybeHandle<Object>();
12035 } 12039 }
12036 12040
12037 12041
12038 Handle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object, 12042 Handle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object,
12039 Handle<Object> structure, 12043 Handle<Object> structure,
12040 uint32_t index, 12044 uint32_t index,
12041 Handle<Object> value, 12045 Handle<Object> value,
12042 Handle<JSObject> holder, 12046 Handle<JSObject> holder,
12043 StrictMode strict_mode) { 12047 StrictMode strict_mode) {
12044 Isolate* isolate = object->GetIsolate(); 12048 Isolate* isolate = object->GetIsolate();
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
12984 { MaybeObject* maybe_len = 12988 { MaybeObject* maybe_len =
12985 GetHeap()->NumberFromDouble(static_cast<double>(index) + 1); 12989 GetHeap()->NumberFromDouble(static_cast<double>(index) + 1);
12986 if (!maybe_len->ToObject(&len)) return maybe_len; 12990 if (!maybe_len->ToObject(&len)) return maybe_len;
12987 } 12991 }
12988 set_length(len); 12992 set_length(len);
12989 } 12993 }
12990 return value; 12994 return value;
12991 } 12995 }
12992 12996
12993 12997
12994 Handle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, 12998 MaybeHandle<Object> JSObject::GetElementWithInterceptor(
12995 Handle<Object> receiver, 12999 Handle<JSObject> object,
12996 uint32_t index) { 13000 Handle<Object> receiver,
13001 uint32_t index) {
12997 Isolate* isolate = object->GetIsolate(); 13002 Isolate* isolate = object->GetIsolate();
12998 13003
12999 // Make sure that the top context does not change when doing 13004 // Make sure that the top context does not change when doing
13000 // callbacks or interceptor calls. 13005 // callbacks or interceptor calls.
13001 AssertNoContextChange ncc(isolate); 13006 AssertNoContextChange ncc(isolate);
13002 13007
13003 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor(), isolate); 13008 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor(), isolate);
13004 if (!interceptor->getter()->IsUndefined()) { 13009 if (!interceptor->getter()->IsUndefined()) {
13005 v8::IndexedPropertyGetterCallback getter = 13010 v8::IndexedPropertyGetterCallback getter =
13006 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); 13011 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
13007 LOG(isolate, 13012 LOG(isolate,
13008 ApiIndexedPropertyAccess("interceptor-indexed-get", *object, index)); 13013 ApiIndexedPropertyAccess("interceptor-indexed-get", *object, index));
13009 PropertyCallbackArguments 13014 PropertyCallbackArguments
13010 args(isolate, interceptor->data(), *receiver, *object); 13015 args(isolate, interceptor->data(), *receiver, *object);
13011 v8::Handle<v8::Value> result = args.Call(getter, index); 13016 v8::Handle<v8::Value> result = args.Call(getter, index);
13012 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 13017 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
13013 if (!result.IsEmpty()) { 13018 if (!result.IsEmpty()) {
13014 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 13019 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
13015 result_internal->VerifyApiCallResultType(); 13020 result_internal->VerifyApiCallResultType();
13016 // Rebox handle before return. 13021 // Rebox handle before return.
13017 return Handle<Object>(*result_internal, isolate); 13022 return handle(*result_internal, isolate);
13018 } 13023 }
13019 } 13024 }
13020 13025
13021 ElementsAccessor* handler = object->GetElementsAccessor(); 13026 ElementsAccessor* handler = object->GetElementsAccessor();
13022 Handle<Object> result = handler->Get(receiver, object, index); 13027 Handle<Object> result;
13023 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); 13028 ASSIGN_RETURN_ON_EXCEPTION(
13029 isolate, result, handler->Get(receiver, object, index),
13030 Object);
13024 if (!result->IsTheHole()) return result; 13031 if (!result->IsTheHole()) return result;
13025 13032
13026 Handle<Object> proto(object->GetPrototype(), isolate); 13033 Handle<Object> proto(object->GetPrototype(), isolate);
13027 if (proto->IsNull()) return isolate->factory()->undefined_value(); 13034 if (proto->IsNull()) return isolate->factory()->undefined_value();
13028 return Object::GetElementWithReceiver(isolate, proto, receiver, index); 13035 return Object::GetElementWithReceiver(isolate, proto, receiver, index);
13029 } 13036 }
13030 13037
13031 13038
13032 bool JSObject::HasDenseElements() { 13039 bool JSObject::HasDenseElements() {
13033 int capacity = 0; 13040 int capacity = 0;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
13313 ApiNamedPropertyAccess("interceptor-named-get", *object, *name)); 13320 ApiNamedPropertyAccess("interceptor-named-get", *object, *name));
13314 PropertyCallbackArguments 13321 PropertyCallbackArguments
13315 args(isolate, interceptor->data(), *receiver, *object); 13322 args(isolate, interceptor->data(), *receiver, *object);
13316 v8::Handle<v8::Value> result = 13323 v8::Handle<v8::Value> result =
13317 args.Call(getter, v8::Utils::ToLocal(name_string)); 13324 args.Call(getter, v8::Utils::ToLocal(name_string));
13318 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 13325 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
13319 if (!result.IsEmpty()) { 13326 if (!result.IsEmpty()) {
13320 *attributes = NONE; 13327 *attributes = NONE;
13321 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 13328 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
13322 result_internal->VerifyApiCallResultType(); 13329 result_internal->VerifyApiCallResultType();
13323 // Rebox handle to escape this scope. 13330 // Rebox handle before return.
13324 return handle(*result_internal, isolate); 13331 return handle(*result_internal, isolate);
13325 } 13332 }
13326 } 13333 }
13327 13334
13328 return GetPropertyPostInterceptor(object, receiver, name, attributes); 13335 return GetPropertyPostInterceptor(object, receiver, name, attributes);
13329 } 13336 }
13330 13337
13331 13338
13332 bool JSObject::HasRealNamedProperty(Handle<JSObject> object, 13339 bool JSObject::HasRealNamedProperty(Handle<JSObject> object,
13333 Handle<Name> key) { 13340 Handle<Name> key) {
(...skipping 3337 matching lines...) Expand 10 before | Expand all | Expand 10 after
16671 #define ERROR_MESSAGES_TEXTS(C, T) T, 16678 #define ERROR_MESSAGES_TEXTS(C, T) T,
16672 static const char* error_messages_[] = { 16679 static const char* error_messages_[] = {
16673 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16680 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16674 }; 16681 };
16675 #undef ERROR_MESSAGES_TEXTS 16682 #undef ERROR_MESSAGES_TEXTS
16676 return error_messages_[reason]; 16683 return error_messages_[reason];
16677 } 16684 }
16678 16685
16679 16686
16680 } } // namespace v8::internal 16687 } } // namespace v8::internal
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