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

Side by Side Diff: src/objects.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixing wrongly wrapped lines Created 4 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 Object); 621 Object);
622 } 622 }
623 623
624 // Lookup the @@hasInstance method on {callable}. 624 // Lookup the @@hasInstance method on {callable}.
625 Handle<Object> inst_of_handler; 625 Handle<Object> inst_of_handler;
626 ASSIGN_RETURN_ON_EXCEPTION( 626 ASSIGN_RETURN_ON_EXCEPTION(
627 isolate, inst_of_handler, 627 isolate, inst_of_handler,
628 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable), 628 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable),
629 isolate->factory()->has_instance_symbol()), 629 isolate->factory()->has_instance_symbol()),
630 Object); 630 Object);
631 if (!inst_of_handler->IsUndefined()) { 631 if (!inst_of_handler->IsUndefined(isolate)) {
632 // Call the {inst_of_handler} on the {callable}. 632 // Call the {inst_of_handler} on the {callable}.
633 Handle<Object> result; 633 Handle<Object> result;
634 ASSIGN_RETURN_ON_EXCEPTION( 634 ASSIGN_RETURN_ON_EXCEPTION(
635 isolate, result, 635 isolate, result,
636 Execution::Call(isolate, inst_of_handler, callable, 1, &object), 636 Execution::Call(isolate, inst_of_handler, callable, 1, &object),
637 Object); 637 Object);
638 return isolate->factory()->ToBoolean(result->BooleanValue()); 638 return isolate->factory()->ToBoolean(result->BooleanValue());
639 } 639 }
640 } 640 }
641 641
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 685 }
686 686
687 687
688 // static 688 // static
689 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver, 689 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver,
690 Handle<Name> name) { 690 Handle<Name> name) {
691 Handle<Object> func; 691 Handle<Object> func;
692 Isolate* isolate = receiver->GetIsolate(); 692 Isolate* isolate = receiver->GetIsolate();
693 ASSIGN_RETURN_ON_EXCEPTION(isolate, func, 693 ASSIGN_RETURN_ON_EXCEPTION(isolate, func,
694 JSReceiver::GetProperty(receiver, name), Object); 694 JSReceiver::GetProperty(receiver, name), Object);
695 if (func->IsNull() || func->IsUndefined()) { 695 if (func->IsNull() || func->IsUndefined(isolate)) {
696 return isolate->factory()->undefined_value(); 696 return isolate->factory()->undefined_value();
697 } 697 }
698 if (!func->IsCallable()) { 698 if (!func->IsCallable()) {
699 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction, 699 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction,
700 func, name, receiver), 700 func, name, receiver),
701 Object); 701 Object);
702 } 702 }
703 return func; 703 return func;
704 } 704 }
705 705
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 Object); 880 Object);
881 } 881 }
882 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 882 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
883 Handle<JSReceiver> target(proxy->target(), isolate); 883 Handle<JSReceiver> target(proxy->target(), isolate);
884 // 6. Let trap be ? GetMethod(handler, "get"). 884 // 6. Let trap be ? GetMethod(handler, "get").
885 Handle<Object> trap; 885 Handle<Object> trap;
886 ASSIGN_RETURN_ON_EXCEPTION( 886 ASSIGN_RETURN_ON_EXCEPTION(
887 isolate, trap, 887 isolate, trap,
888 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object); 888 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object);
889 // 7. If trap is undefined, then 889 // 7. If trap is undefined, then
890 if (trap->IsUndefined()) { 890 if (trap->IsUndefined(isolate)) {
891 // 7.a Return target.[[Get]](P, Receiver). 891 // 7.a Return target.[[Get]](P, Receiver).
892 LookupIterator it = 892 LookupIterator it =
893 LookupIterator::PropertyOrElement(isolate, receiver, name, target); 893 LookupIterator::PropertyOrElement(isolate, receiver, name, target);
894 MaybeHandle<Object> result = Object::GetProperty(&it); 894 MaybeHandle<Object> result = Object::GetProperty(&it);
895 *was_found = it.IsFound(); 895 *was_found = it.IsFound();
896 return result; 896 return result;
897 } 897 }
898 // 8. Let trapResult be ? Call(trap, handler, «target, P, Receiver»). 898 // 8. Let trapResult be ? Call(trap, handler, «target, P, Receiver»).
899 Handle<Object> trap_result; 899 Handle<Object> trap_result;
900 Handle<Object> args[] = {target, name, receiver}; 900 Handle<Object> args[] = {target, name, receiver};
(...skipping 19 matching lines...) Expand all
920 THROW_NEW_ERROR( 920 THROW_NEW_ERROR(
921 isolate, NewTypeError(MessageTemplate::kProxyGetNonConfigurableData, 921 isolate, NewTypeError(MessageTemplate::kProxyGetNonConfigurableData,
922 name, target_desc.value(), trap_result), 922 name, target_desc.value(), trap_result),
923 Object); 923 Object);
924 } 924 }
925 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]] 925 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]]
926 // is false and targetDesc.[[Get]] is undefined, then 926 // is false and targetDesc.[[Get]] is undefined, then
927 // 10.b.i. If trapResult is not undefined, throw a TypeError exception. 927 // 10.b.i. If trapResult is not undefined, throw a TypeError exception.
928 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && 928 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
929 !target_desc.configurable() && 929 !target_desc.configurable() &&
930 target_desc.get()->IsUndefined() && 930 target_desc.get()->IsUndefined(isolate) &&
931 !trap_result->IsUndefined(); 931 !trap_result->IsUndefined(isolate);
932 if (inconsistent) { 932 if (inconsistent) {
933 THROW_NEW_ERROR( 933 THROW_NEW_ERROR(
934 isolate, 934 isolate,
935 NewTypeError(MessageTemplate::kProxyGetNonConfigurableAccessor, name, 935 NewTypeError(MessageTemplate::kProxyGetNonConfigurableAccessor, name,
936 trap_result), 936 trap_result),
937 Object); 937 Object);
938 } 938 }
939 } 939 }
940 // 11. Return trap_result 940 // 11. Return trap_result
941 return trap_result; 941 return trap_result;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 } 1013 }
1014 1014
1015 1015
1016 // TODO(dcarney): CallOptimization duplicates this logic, merge. 1016 // TODO(dcarney): CallOptimization duplicates this logic, merge.
1017 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate, 1017 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate,
1018 Object* receiver) { 1018 Object* receiver) {
1019 // API calls are only supported with JSObject receivers. 1019 // API calls are only supported with JSObject receivers.
1020 if (!receiver->IsJSObject()) return isolate->heap()->null_value(); 1020 if (!receiver->IsJSObject()) return isolate->heap()->null_value();
1021 Object* recv_type = this->signature(); 1021 Object* recv_type = this->signature();
1022 // No signature, return holder. 1022 // No signature, return holder.
1023 if (recv_type->IsUndefined()) return receiver; 1023 if (recv_type->IsUndefined(isolate)) return receiver;
1024 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type); 1024 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
1025 // Check the receiver. 1025 // Check the receiver.
1026 for (PrototypeIterator iter(isolate, JSObject::cast(receiver), 1026 for (PrototypeIterator iter(isolate, JSObject::cast(receiver),
1027 PrototypeIterator::START_AT_RECEIVER, 1027 PrototypeIterator::START_AT_RECEIVER,
1028 PrototypeIterator::END_AT_NON_HIDDEN); 1028 PrototypeIterator::END_AT_NON_HIDDEN);
1029 !iter.IsAtEnd(); iter.Advance()) { 1029 !iter.IsAtEnd(); iter.Advance()) {
1030 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent(); 1030 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent();
1031 } 1031 }
1032 return isolate->heap()->null_value(); 1032 return isolate->heap()->null_value();
1033 } 1033 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 Object); 1092 Object);
1093 } 1093 }
1094 Handle<JSReceiver> target(proxy->target(), isolate); 1094 Handle<JSReceiver> target(proxy->target(), isolate);
1095 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 1095 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
1096 1096
1097 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf"). 1097 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf").
1098 Handle<Object> trap; 1098 Handle<Object> trap;
1099 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name), 1099 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name),
1100 Object); 1100 Object);
1101 // 6. If trap is undefined, then return target.[[GetPrototypeOf]](). 1101 // 6. If trap is undefined, then return target.[[GetPrototypeOf]]().
1102 if (trap->IsUndefined()) { 1102 if (trap->IsUndefined(isolate)) {
1103 return JSReceiver::GetPrototype(isolate, target); 1103 return JSReceiver::GetPrototype(isolate, target);
1104 } 1104 }
1105 // 7. Let handlerProto be ? Call(trap, handler, «target»). 1105 // 7. Let handlerProto be ? Call(trap, handler, «target»).
1106 Handle<Object> argv[] = {target}; 1106 Handle<Object> argv[] = {target};
1107 Handle<Object> handler_proto; 1107 Handle<Object> handler_proto;
1108 ASSIGN_RETURN_ON_EXCEPTION( 1108 ASSIGN_RETURN_ON_EXCEPTION(
1109 isolate, handler_proto, 1109 isolate, handler_proto,
1110 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object); 1110 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object);
1111 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError. 1111 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError.
1112 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) { 1112 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (!name->IsUniqueName()) { 1439 if (!name->IsUniqueName()) {
1440 name = object->GetIsolate()->factory()->InternalizeString( 1440 name = object->GetIsolate()->factory()->InternalizeString(
1441 Handle<String>::cast(name)); 1441 Handle<String>::cast(name));
1442 } 1442 }
1443 1443
1444 if (object->IsJSGlobalObject()) { 1444 if (object->IsJSGlobalObject()) {
1445 Handle<GlobalDictionary> property_dictionary(object->global_dictionary()); 1445 Handle<GlobalDictionary> property_dictionary(object->global_dictionary());
1446 1446
1447 int entry = property_dictionary->FindEntry(name); 1447 int entry = property_dictionary->FindEntry(name);
1448 if (entry == GlobalDictionary::kNotFound) { 1448 if (entry == GlobalDictionary::kNotFound) {
1449 auto cell = object->GetIsolate()->factory()->NewPropertyCell(); 1449 Isolate* isolate = object->GetIsolate();
1450 auto cell = isolate->factory()->NewPropertyCell();
1450 cell->set_value(*value); 1451 cell->set_value(*value);
1451 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined 1452 auto cell_type = value->IsUndefined(isolate)
1452 : PropertyCellType::kConstant; 1453 ? PropertyCellType::kUndefined
1454 : PropertyCellType::kConstant;
1453 details = details.set_cell_type(cell_type); 1455 details = details.set_cell_type(cell_type);
1454 value = cell; 1456 value = cell;
1455 property_dictionary = 1457 property_dictionary =
1456 GlobalDictionary::Add(property_dictionary, name, value, details); 1458 GlobalDictionary::Add(property_dictionary, name, value, details);
1457 object->set_properties(*property_dictionary); 1459 object->set_properties(*property_dictionary);
1458 } else { 1460 } else {
1459 PropertyCell::UpdateCell(property_dictionary, entry, value, details); 1461 PropertyCell::UpdateCell(property_dictionary, entry, value, details);
1460 } 1462 }
1461 } else { 1463 } else {
1462 Handle<NameDictionary> property_dictionary(object->property_dictionary()); 1464 Handle<NameDictionary> property_dictionary(object->property_dictionary());
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 ASSIGN_RETURN_ON_EXCEPTION( 1683 ASSIGN_RETURN_ON_EXCEPTION(
1682 isolate, constructor, 1684 isolate, constructor,
1683 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor), 1685 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor),
1684 isolate->factory()->species_symbol()), 1686 isolate->factory()->species_symbol()),
1685 Object); 1687 Object);
1686 if (constructor->IsNull()) { 1688 if (constructor->IsNull()) {
1687 constructor = isolate->factory()->undefined_value(); 1689 constructor = isolate->factory()->undefined_value();
1688 } 1690 }
1689 } 1691 }
1690 } 1692 }
1691 if (constructor->IsUndefined()) { 1693 if (constructor->IsUndefined(isolate)) {
1692 return default_species; 1694 return default_species;
1693 } else { 1695 } else {
1694 if (!constructor->IsConstructor()) { 1696 if (!constructor->IsConstructor()) {
1695 THROW_NEW_ERROR(isolate, 1697 THROW_NEW_ERROR(isolate,
1696 NewTypeError(MessageTemplate::kSpeciesNotConstructor), 1698 NewTypeError(MessageTemplate::kSpeciesNotConstructor),
1697 Object); 1699 Object);
1698 } 1700 }
1699 return constructor; 1701 return constructor;
1700 } 1702 }
1701 } 1703 }
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 // Need to adjust the details. 2717 // Need to adjust the details.
2716 int index = dict->NextEnumerationIndex(); 2718 int index = dict->NextEnumerationIndex();
2717 dict->SetNextEnumerationIndex(index + 1); 2719 dict->SetNextEnumerationIndex(index + 1);
2718 PropertyCell* cell = PropertyCell::cast(dict->ValueAt(entry)); 2720 PropertyCell* cell = PropertyCell::cast(dict->ValueAt(entry));
2719 details = cell->property_details().set_index(index); 2721 details = cell->property_details().set_index(index);
2720 cell->set_property_details(details); 2722 cell->set_property_details(details);
2721 2723
2722 } else { 2724 } else {
2723 auto cell = isolate->factory()->NewPropertyCell(); 2725 auto cell = isolate->factory()->NewPropertyCell();
2724 cell->set_value(*value); 2726 cell->set_value(*value);
2725 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined 2727 auto cell_type = value->IsUndefined(isolate)
2726 : PropertyCellType::kConstant; 2728 ? PropertyCellType::kUndefined
2729 : PropertyCellType::kConstant;
2727 details = details.set_cell_type(cell_type); 2730 details = details.set_cell_type(cell_type);
2728 value = cell; 2731 value = cell;
2729 2732
2730 Handle<GlobalDictionary> result = 2733 Handle<GlobalDictionary> result =
2731 GlobalDictionary::Add(dict, name, value, details); 2734 GlobalDictionary::Add(dict, name, value, details);
2732 if (*dict != *result) object->set_properties(*result); 2735 if (*dict != *result) object->set_properties(*result);
2733 } 2736 }
2734 } else { 2737 } else {
2735 Handle<NameDictionary> dict(object->property_dictionary()); 2738 Handle<NameDictionary> dict(object->property_dictionary());
2736 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 2739 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds. 3299 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds.
3297 // TODO(ishell): compare AccessorPairs. 3300 // TODO(ishell): compare AccessorPairs.
3298 return false; 3301 return false;
3299 } 3302 }
3300 3303
3301 3304
3302 // Installs |new_descriptors| over the current instance_descriptors to ensure 3305 // Installs |new_descriptors| over the current instance_descriptors to ensure
3303 // proper sharing of descriptor arrays. 3306 // proper sharing of descriptor arrays.
3304 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors, 3307 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors,
3305 LayoutDescriptor* new_layout_descriptor) { 3308 LayoutDescriptor* new_layout_descriptor) {
3309 Isolate* isolate = GetIsolate();
3306 // Don't overwrite the empty descriptor array or initial map's descriptors. 3310 // Don't overwrite the empty descriptor array or initial map's descriptors.
3307 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined()) { 3311 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined(isolate)) {
3308 return; 3312 return;
3309 } 3313 }
3310 3314
3311 DescriptorArray* to_replace = instance_descriptors(); 3315 DescriptorArray* to_replace = instance_descriptors();
3312 GetHeap()->incremental_marking()->IterateBlackObject(to_replace); 3316 isolate->heap()->incremental_marking()->IterateBlackObject(to_replace);
3313 Map* current = this; 3317 Map* current = this;
3314 while (current->instance_descriptors() == to_replace) { 3318 while (current->instance_descriptors() == to_replace) {
3315 Object* next = current->GetBackPointer(); 3319 Object* next = current->GetBackPointer();
3316 if (next->IsUndefined()) break; // Stop overwriting at initial map. 3320 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
3317 current->SetEnumLength(kInvalidEnumCacheSentinel); 3321 current->SetEnumLength(kInvalidEnumCacheSentinel);
3318 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); 3322 current->UpdateDescriptors(new_descriptors, new_layout_descriptor);
3319 current = Map::cast(next); 3323 current = Map::cast(next);
3320 } 3324 }
3321 set_owns_descriptors(false); 3325 set_owns_descriptors(false);
3322 } 3326 }
3323 3327
3324 3328
3325 Map* Map::FindRootMap() { 3329 Map* Map::FindRootMap() {
3326 Map* result = this; 3330 Map* result = this;
3331 Isolate* isolate = GetIsolate();
3327 while (true) { 3332 while (true) {
3328 Object* back = result->GetBackPointer(); 3333 Object* back = result->GetBackPointer();
3329 if (back->IsUndefined()) { 3334 if (back->IsUndefined(isolate)) {
3330 // Initial map always owns descriptors and doesn't have unused entries 3335 // Initial map always owns descriptors and doesn't have unused entries
3331 // in the descriptor array. 3336 // in the descriptor array.
3332 DCHECK(result->owns_descriptors()); 3337 DCHECK(result->owns_descriptors());
3333 DCHECK_EQ(result->NumberOfOwnDescriptors(), 3338 DCHECK_EQ(result->NumberOfOwnDescriptors(),
3334 result->instance_descriptors()->number_of_descriptors()); 3339 result->instance_descriptors()->number_of_descriptors());
3335 return result; 3340 return result;
3336 } 3341 }
3337 result = Map::cast(back); 3342 result = Map::cast(back);
3338 } 3343 }
3339 } 3344 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3377 current = next; 3382 current = next;
3378 } 3383 }
3379 return current; 3384 return current;
3380 } 3385 }
3381 3386
3382 3387
3383 Map* Map::FindFieldOwner(int descriptor) { 3388 Map* Map::FindFieldOwner(int descriptor) {
3384 DisallowHeapAllocation no_allocation; 3389 DisallowHeapAllocation no_allocation;
3385 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type()); 3390 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type());
3386 Map* result = this; 3391 Map* result = this;
3392 Isolate* isolate = GetIsolate();
3387 while (true) { 3393 while (true) {
3388 Object* back = result->GetBackPointer(); 3394 Object* back = result->GetBackPointer();
3389 if (back->IsUndefined()) break; 3395 if (back->IsUndefined(isolate)) break;
3390 Map* parent = Map::cast(back); 3396 Map* parent = Map::cast(back);
3391 if (parent->NumberOfOwnDescriptors() <= descriptor) break; 3397 if (parent->NumberOfOwnDescriptors() <= descriptor) break;
3392 result = parent; 3398 result = parent;
3393 } 3399 }
3394 return result; 3400 return result;
3395 } 3401 }
3396 3402
3397 3403
3398 void Map::UpdateFieldType(int descriptor, Handle<Name> name, 3404 void Map::UpdateFieldType(int descriptor, Handle<Name> name,
3399 Representation new_representation, 3405 Representation new_representation,
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it, 4189 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it,
4184 ShouldThrow should_throw, 4190 ShouldThrow should_throw,
4185 Handle<Object> value) { 4191 Handle<Object> value) {
4186 Isolate* isolate = it->isolate(); 4192 Isolate* isolate = it->isolate();
4187 // Make sure that the top context does not change when doing callbacks or 4193 // Make sure that the top context does not change when doing callbacks or
4188 // interceptor calls. 4194 // interceptor calls.
4189 AssertNoContextChange ncc(isolate); 4195 AssertNoContextChange ncc(isolate);
4190 4196
4191 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 4197 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
4192 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); 4198 Handle<InterceptorInfo> interceptor(it->GetInterceptor());
4193 if (interceptor->setter()->IsUndefined()) return Just(false); 4199 if (interceptor->setter()->IsUndefined(isolate)) return Just(false);
4194 4200
4195 Handle<JSObject> holder = it->GetHolder<JSObject>(); 4201 Handle<JSObject> holder = it->GetHolder<JSObject>();
4196 bool result; 4202 bool result;
4197 Handle<Object> receiver = it->GetReceiver(); 4203 Handle<Object> receiver = it->GetReceiver();
4198 if (!receiver->IsJSReceiver()) { 4204 if (!receiver->IsJSReceiver()) {
4199 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 4205 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
4200 Object::ConvertReceiver(isolate, receiver), 4206 Object::ConvertReceiver(isolate, receiver),
4201 Nothing<bool>()); 4207 Nothing<bool>());
4202 } 4208 }
4203 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 4209 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4494 // Proxies are handled elsewhere. Other non-JSObjects cannot have own 4500 // Proxies are handled elsewhere. Other non-JSObjects cannot have own
4495 // properties. 4501 // properties.
4496 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); 4502 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver());
4497 4503
4498 // Store on the holder which may be hidden behind the receiver. 4504 // Store on the holder which may be hidden behind the receiver.
4499 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); 4505 DCHECK(it->HolderIsReceiverOrHiddenPrototype());
4500 4506
4501 Handle<Object> to_assign = value; 4507 Handle<Object> to_assign = value;
4502 // Convert the incoming value to a number for storing into typed arrays. 4508 // Convert the incoming value to a number for storing into typed arrays.
4503 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) { 4509 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) {
4504 if (!value->IsNumber() && !value->IsUndefined()) { 4510 if (!value->IsNumber() && !value->IsUndefined(it->isolate())) {
4505 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4511 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4506 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>()); 4512 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>());
4507 // We have to recheck the length. However, it can only change if the 4513 // We have to recheck the length. However, it can only change if the
4508 // underlying buffer was neutered, so just check that. 4514 // underlying buffer was neutered, so just check that.
4509 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { 4515 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) {
4510 return Just(true); 4516 return Just(true);
4511 // TODO(neis): According to the spec, this should throw a TypeError. 4517 // TODO(neis): According to the spec, this should throw a TypeError.
4512 } 4518 }
4513 } 4519 }
4514 } 4520 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 4639
4634 // If the source descriptors had an enum cache we copy it. This ensures 4640 // If the source descriptors had an enum cache we copy it. This ensures
4635 // that the maps to which we push the new descriptor array back can rely 4641 // that the maps to which we push the new descriptor array back can rely
4636 // on a cache always being available once it is set. If the map has more 4642 // on a cache always being available once it is set. If the map has more
4637 // enumerated descriptors than available in the original cache, the cache 4643 // enumerated descriptors than available in the original cache, the cache
4638 // will be lazily replaced by the extended cache when needed. 4644 // will be lazily replaced by the extended cache when needed.
4639 if (descriptors->HasEnumCache()) { 4645 if (descriptors->HasEnumCache()) {
4640 new_descriptors->CopyEnumCacheFrom(*descriptors); 4646 new_descriptors->CopyEnumCacheFrom(*descriptors);
4641 } 4647 }
4642 4648
4649 Isolate* isolate = map->GetIsolate();
4643 // Replace descriptors by new_descriptors in all maps that share it. 4650 // Replace descriptors by new_descriptors in all maps that share it.
4644 map->GetHeap()->incremental_marking()->IterateBlackObject(*descriptors); 4651 isolate->heap()->incremental_marking()->IterateBlackObject(*descriptors);
4645 4652
4646 Map* current = *map; 4653 Map* current = *map;
4647 while (current->instance_descriptors() == *descriptors) { 4654 while (current->instance_descriptors() == *descriptors) {
4648 Object* next = current->GetBackPointer(); 4655 Object* next = current->GetBackPointer();
4649 if (next->IsUndefined()) break; // Stop overwriting at initial map. 4656 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
4650 current->UpdateDescriptors(*new_descriptors, layout_descriptor); 4657 current->UpdateDescriptors(*new_descriptors, layout_descriptor);
4651 current = Map::cast(next); 4658 current = Map::cast(next);
4652 } 4659 }
4653 map->UpdateDescriptors(*new_descriptors, layout_descriptor); 4660 map->UpdateDescriptors(*new_descriptors, layout_descriptor);
4654 } 4661 }
4655 4662
4656 4663
4657 template<class T> 4664 template<class T>
4658 static int AppendUniqueCallbacks(NeanderArray* callbacks, 4665 static int AppendUniqueCallbacks(NeanderArray* callbacks,
4659 Handle<typename T::Array> array, 4666 Handle<typename T::Array> array,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
4957 } 4964 }
4958 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 4965 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
4959 Handle<JSReceiver> target(proxy->target(), isolate); 4966 Handle<JSReceiver> target(proxy->target(), isolate);
4960 // 6. Let trap be ? GetMethod(handler, "has"). 4967 // 6. Let trap be ? GetMethod(handler, "has").
4961 Handle<Object> trap; 4968 Handle<Object> trap;
4962 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4969 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4963 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), 4970 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler),
4964 isolate->factory()->has_string()), 4971 isolate->factory()->has_string()),
4965 Nothing<bool>()); 4972 Nothing<bool>());
4966 // 7. If trap is undefined, then 4973 // 7. If trap is undefined, then
4967 if (trap->IsUndefined()) { 4974 if (trap->IsUndefined(isolate)) {
4968 // 7a. Return target.[[HasProperty]](P). 4975 // 7a. Return target.[[HasProperty]](P).
4969 return JSReceiver::HasProperty(target, name); 4976 return JSReceiver::HasProperty(target, name);
4970 } 4977 }
4971 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)). 4978 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)).
4972 Handle<Object> trap_result_obj; 4979 Handle<Object> trap_result_obj;
4973 Handle<Object> args[] = {target, name}; 4980 Handle<Object> args[] = {target, name};
4974 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4981 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4975 isolate, trap_result_obj, 4982 isolate, trap_result_obj,
4976 Execution::Call(isolate, trap, handler, arraysize(args), args), 4983 Execution::Call(isolate, trap, handler, arraysize(args), args),
4977 Nothing<bool>()); 4984 Nothing<bool>());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 isolate->Throw( 5030 isolate->Throw(
5024 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 5031 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
5025 return Nothing<bool>(); 5032 return Nothing<bool>();
5026 } 5033 }
5027 Handle<JSReceiver> target(proxy->target(), isolate); 5034 Handle<JSReceiver> target(proxy->target(), isolate);
5028 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 5035 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
5029 5036
5030 Handle<Object> trap; 5037 Handle<Object> trap;
5031 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5038 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5032 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 5039 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
5033 if (trap->IsUndefined()) { 5040 if (trap->IsUndefined(isolate)) {
5034 LookupIterator it = 5041 LookupIterator it =
5035 LookupIterator::PropertyOrElement(isolate, receiver, name, target); 5042 LookupIterator::PropertyOrElement(isolate, receiver, name, target);
5036 return Object::SetSuperProperty(&it, value, language_mode, 5043 return Object::SetSuperProperty(&it, value, language_mode,
5037 Object::MAY_BE_STORE_FROM_KEYED); 5044 Object::MAY_BE_STORE_FROM_KEYED);
5038 } 5045 }
5039 5046
5040 Handle<Object> trap_result; 5047 Handle<Object> trap_result;
5041 Handle<Object> args[] = {target, name, value, receiver}; 5048 Handle<Object> args[] = {target, name, value, receiver};
5042 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5049 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5043 isolate, trap_result, 5050 isolate, trap_result,
(...skipping 15 matching lines...) Expand all
5059 !target_desc.configurable() && 5066 !target_desc.configurable() &&
5060 !target_desc.writable() && 5067 !target_desc.writable() &&
5061 !value->SameValue(*target_desc.value()); 5068 !value->SameValue(*target_desc.value());
5062 if (inconsistent) { 5069 if (inconsistent) {
5063 isolate->Throw(*isolate->factory()->NewTypeError( 5070 isolate->Throw(*isolate->factory()->NewTypeError(
5064 MessageTemplate::kProxySetFrozenData, name)); 5071 MessageTemplate::kProxySetFrozenData, name));
5065 return Nothing<bool>(); 5072 return Nothing<bool>();
5066 } 5073 }
5067 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && 5074 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
5068 !target_desc.configurable() && 5075 !target_desc.configurable() &&
5069 target_desc.set()->IsUndefined(); 5076 target_desc.set()->IsUndefined(isolate);
5070 if (inconsistent) { 5077 if (inconsistent) {
5071 isolate->Throw(*isolate->factory()->NewTypeError( 5078 isolate->Throw(*isolate->factory()->NewTypeError(
5072 MessageTemplate::kProxySetFrozenAccessor, name)); 5079 MessageTemplate::kProxySetFrozenAccessor, name));
5073 return Nothing<bool>(); 5080 return Nothing<bool>();
5074 } 5081 }
5075 } 5082 }
5076 return Just(true); 5083 return Just(true);
5077 } 5084 }
5078 5085
5079 5086
(...skipping 12 matching lines...) Expand all
5092 isolate->Throw( 5099 isolate->Throw(
5093 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 5100 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
5094 return Nothing<bool>(); 5101 return Nothing<bool>();
5095 } 5102 }
5096 Handle<JSReceiver> target(proxy->target(), isolate); 5103 Handle<JSReceiver> target(proxy->target(), isolate);
5097 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 5104 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
5098 5105
5099 Handle<Object> trap; 5106 Handle<Object> trap;
5100 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5107 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5101 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 5108 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
5102 if (trap->IsUndefined()) { 5109 if (trap->IsUndefined(isolate)) {
5103 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); 5110 return JSReceiver::DeletePropertyOrElement(target, name, language_mode);
5104 } 5111 }
5105 5112
5106 Handle<Object> trap_result; 5113 Handle<Object> trap_result;
5107 Handle<Object> args[] = {target, name}; 5114 Handle<Object> args[] = {target, name};
5108 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5115 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5109 isolate, trap_result, 5116 isolate, trap_result,
5110 Execution::Call(isolate, trap, handler, arraysize(args), args), 5117 Execution::Call(isolate, trap, handler, arraysize(args), args),
5111 Nothing<bool>()); 5118 Nothing<bool>());
5112 if (!trap_result->BooleanValue()) { 5119 if (!trap_result->BooleanValue()) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
5486 return Just(ABSENT); 5493 return Just(ABSENT);
5487 } 5494 }
5488 Handle<Object> receiver = it->GetReceiver(); 5495 Handle<Object> receiver = it->GetReceiver();
5489 if (!receiver->IsJSReceiver()) { 5496 if (!receiver->IsJSReceiver()) {
5490 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 5497 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
5491 Object::ConvertReceiver(isolate, receiver), 5498 Object::ConvertReceiver(isolate, receiver),
5492 Nothing<PropertyAttributes>()); 5499 Nothing<PropertyAttributes>());
5493 } 5500 }
5494 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 5501 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
5495 *holder, Object::DONT_THROW); 5502 *holder, Object::DONT_THROW);
5496 if (!interceptor->query()->IsUndefined()) { 5503 if (!interceptor->query()->IsUndefined(isolate)) {
5497 Handle<Object> result; 5504 Handle<Object> result;
5498 if (it->IsElement()) { 5505 if (it->IsElement()) {
5499 uint32_t index = it->index(); 5506 uint32_t index = it->index();
5500 v8::IndexedPropertyQueryCallback query = 5507 v8::IndexedPropertyQueryCallback query =
5501 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); 5508 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query());
5502 result = args.Call(query, index); 5509 result = args.Call(query, index);
5503 } else { 5510 } else {
5504 Handle<Name> name = it->name(); 5511 Handle<Name> name = it->name();
5505 DCHECK(!name->IsPrivate()); 5512 DCHECK(!name->IsPrivate());
5506 v8::GenericNamedPropertyQueryCallback query = 5513 v8::GenericNamedPropertyQueryCallback query =
5507 v8::ToCData<v8::GenericNamedPropertyQueryCallback>( 5514 v8::ToCData<v8::GenericNamedPropertyQueryCallback>(
5508 interceptor->query()); 5515 interceptor->query());
5509 result = args.Call(query, name); 5516 result = args.Call(query, name);
5510 } 5517 }
5511 if (!result.is_null()) { 5518 if (!result.is_null()) {
5512 int32_t value; 5519 int32_t value;
5513 CHECK(result->ToInt32(&value)); 5520 CHECK(result->ToInt32(&value));
5514 return Just(static_cast<PropertyAttributes>(value)); 5521 return Just(static_cast<PropertyAttributes>(value));
5515 } 5522 }
5516 } else if (!interceptor->getter()->IsUndefined()) { 5523 } else if (!interceptor->getter()->IsUndefined(isolate)) {
5517 // TODO(verwaest): Use GetPropertyWithInterceptor? 5524 // TODO(verwaest): Use GetPropertyWithInterceptor?
5518 Handle<Object> result; 5525 Handle<Object> result;
5519 if (it->IsElement()) { 5526 if (it->IsElement()) {
5520 uint32_t index = it->index(); 5527 uint32_t index = it->index();
5521 v8::IndexedPropertyGetterCallback getter = 5528 v8::IndexedPropertyGetterCallback getter =
5522 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); 5529 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
5523 result = args.Call(getter, index); 5530 result = args.Call(getter, index);
5524 } else { 5531 } else {
5525 Handle<Name> name = it->name(); 5532 Handle<Name> name = it->name();
5526 DCHECK(!name->IsPrivate()); 5533 DCHECK(!name->IsPrivate());
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
5926 5933
5927 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it, 5934 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it,
5928 ShouldThrow should_throw) { 5935 ShouldThrow should_throw) {
5929 Isolate* isolate = it->isolate(); 5936 Isolate* isolate = it->isolate();
5930 // Make sure that the top context does not change when doing callbacks or 5937 // Make sure that the top context does not change when doing callbacks or
5931 // interceptor calls. 5938 // interceptor calls.
5932 AssertNoContextChange ncc(isolate); 5939 AssertNoContextChange ncc(isolate);
5933 5940
5934 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 5941 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
5935 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); 5942 Handle<InterceptorInfo> interceptor(it->GetInterceptor());
5936 if (interceptor->deleter()->IsUndefined()) return Nothing<bool>(); 5943 if (interceptor->deleter()->IsUndefined(isolate)) return Nothing<bool>();
5937 5944
5938 Handle<JSObject> holder = it->GetHolder<JSObject>(); 5945 Handle<JSObject> holder = it->GetHolder<JSObject>();
5939 Handle<Object> receiver = it->GetReceiver(); 5946 Handle<Object> receiver = it->GetReceiver();
5940 if (!receiver->IsJSReceiver()) { 5947 if (!receiver->IsJSReceiver()) {
5941 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 5948 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
5942 Object::ConvertReceiver(isolate, receiver), 5949 Object::ConvertReceiver(isolate, receiver),
5943 Nothing<bool>()); 5950 Nothing<bool>());
5944 } 5951 }
5945 5952
5946 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 5953 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6863 } 6870 }
6864 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 6871 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
6865 Handle<JSReceiver> target(proxy->target(), isolate); 6872 Handle<JSReceiver> target(proxy->target(), isolate);
6866 // 6. Let trap be ? GetMethod(handler, "defineProperty"). 6873 // 6. Let trap be ? GetMethod(handler, "defineProperty").
6867 Handle<Object> trap; 6874 Handle<Object> trap;
6868 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 6875 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6869 isolate, trap, 6876 isolate, trap,
6870 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 6877 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
6871 Nothing<bool>()); 6878 Nothing<bool>());
6872 // 7. If trap is undefined, then: 6879 // 7. If trap is undefined, then:
6873 if (trap->IsUndefined()) { 6880 if (trap->IsUndefined(isolate)) {
6874 // 7a. Return target.[[DefineOwnProperty]](P, Desc). 6881 // 7a. Return target.[[DefineOwnProperty]](P, Desc).
6875 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, 6882 return JSReceiver::DefineOwnProperty(isolate, target, key, desc,
6876 should_throw); 6883 should_throw);
6877 } 6884 }
6878 // 8. Let descObj be FromPropertyDescriptor(Desc). 6885 // 8. Let descObj be FromPropertyDescriptor(Desc).
6879 Handle<Object> desc_obj = desc->ToObject(isolate); 6886 Handle<Object> desc_obj = desc->ToObject(isolate);
6880 // 9. Let booleanTrapResult be 6887 // 9. Let booleanTrapResult be
6881 // ToBoolean(? Call(trap, handler, «target, P, descObj»)). 6888 // ToBoolean(? Call(trap, handler, «target, P, descObj»)).
6882 Handle<Name> property_name = 6889 Handle<Name> property_name =
6883 key->IsName() 6890 key->IsName()
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
7081 } 7088 }
7082 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 7089 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
7083 Handle<JSReceiver> target(proxy->target(), isolate); 7090 Handle<JSReceiver> target(proxy->target(), isolate);
7084 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). 7091 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor").
7085 Handle<Object> trap; 7092 Handle<Object> trap;
7086 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7093 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7087 isolate, trap, 7094 isolate, trap,
7088 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 7095 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
7089 Nothing<bool>()); 7096 Nothing<bool>());
7090 // 7. If trap is undefined, then 7097 // 7. If trap is undefined, then
7091 if (trap->IsUndefined()) { 7098 if (trap->IsUndefined(isolate)) {
7092 // 7a. Return target.[[GetOwnProperty]](P). 7099 // 7a. Return target.[[GetOwnProperty]](P).
7093 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); 7100 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc);
7094 } 7101 }
7095 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»). 7102 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»).
7096 Handle<Object> trap_result_obj; 7103 Handle<Object> trap_result_obj;
7097 Handle<Object> args[] = {target, name}; 7104 Handle<Object> args[] = {target, name};
7098 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7105 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7099 isolate, trap_result_obj, 7106 isolate, trap_result_obj,
7100 Execution::Call(isolate, trap, handler, arraysize(args), args), 7107 Execution::Call(isolate, trap, handler, arraysize(args), args),
7101 Nothing<bool>()); 7108 Nothing<bool>());
7102 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a 7109 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a
7103 // TypeError exception. 7110 // TypeError exception.
7104 if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) { 7111 if (!trap_result_obj->IsJSReceiver() &&
7112 !trap_result_obj->IsUndefined(isolate)) {
7105 isolate->Throw(*isolate->factory()->NewTypeError( 7113 isolate->Throw(*isolate->factory()->NewTypeError(
7106 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name)); 7114 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name));
7107 return Nothing<bool>(); 7115 return Nothing<bool>();
7108 } 7116 }
7109 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). 7117 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P).
7110 PropertyDescriptor target_desc; 7118 PropertyDescriptor target_desc;
7111 Maybe<bool> found = 7119 Maybe<bool> found =
7112 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); 7120 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
7113 MAYBE_RETURN(found, Nothing<bool>()); 7121 MAYBE_RETURN(found, Nothing<bool>());
7114 // 11. If trapResultObj is undefined, then 7122 // 11. If trapResultObj is undefined, then
7115 if (trap_result_obj->IsUndefined()) { 7123 if (trap_result_obj->IsUndefined(isolate)) {
7116 // 11a. If targetDesc is undefined, return undefined. 7124 // 11a. If targetDesc is undefined, return undefined.
7117 if (!found.FromJust()) return Just(false); 7125 if (!found.FromJust()) return Just(false);
7118 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError 7126 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError
7119 // exception. 7127 // exception.
7120 if (!target_desc.configurable()) { 7128 if (!target_desc.configurable()) {
7121 isolate->Throw(*isolate->factory()->NewTypeError( 7129 isolate->Throw(*isolate->factory()->NewTypeError(
7122 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name)); 7130 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name));
7123 return Nothing<bool>(); 7131 return Nothing<bool>();
7124 } 7132 }
7125 // 11c. Let extensibleTarget be ? IsExtensible(target). 7133 // 11c. Let extensibleTarget be ? IsExtensible(target).
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
7170 } 7178 }
7171 } 7179 }
7172 // 18. Return resultDesc. 7180 // 18. Return resultDesc.
7173 return Just(true); 7181 return Just(true);
7174 } 7182 }
7175 7183
7176 7184
7177 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, 7185 bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
7178 ElementsKind kind, 7186 ElementsKind kind,
7179 Object* object) { 7187 Object* object) {
7188 Isolate* isolate = elements->GetIsolate();
7180 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) { 7189 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) {
7181 int length = IsJSArray() 7190 int length = IsJSArray()
7182 ? Smi::cast(JSArray::cast(this)->length())->value() 7191 ? Smi::cast(JSArray::cast(this)->length())->value()
7183 : elements->length(); 7192 : elements->length();
7184 for (int i = 0; i < length; ++i) { 7193 for (int i = 0; i < length; ++i) {
7185 Object* element = elements->get(i); 7194 Object* element = elements->get(i);
7186 if (!element->IsTheHole() && element == object) return true; 7195 if (!element->IsTheHole(isolate) && element == object) return true;
7187 } 7196 }
7188 } else { 7197 } else {
7189 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS); 7198 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS);
7190 Object* key = 7199 Object* key =
7191 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object); 7200 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object);
7192 if (!key->IsUndefined()) return true; 7201 if (!key->IsUndefined(isolate)) return true;
7193 } 7202 }
7194 return false; 7203 return false;
7195 } 7204 }
7196 7205
7197 7206
7198 // Check whether this object references another object. 7207 // Check whether this object references another object.
7199 bool JSObject::ReferencesObject(Object* obj) { 7208 bool JSObject::ReferencesObject(Object* obj) {
7200 Map* map_of_this = map(); 7209 Map* map_of_this = map();
7201 Heap* heap = GetHeap(); 7210 Heap* heap = GetHeap();
7202 DisallowHeapAllocation no_allocation; 7211 DisallowHeapAllocation no_allocation;
7203 7212
7204 // Is the object the constructor for this object? 7213 // Is the object the constructor for this object?
7205 if (map_of_this->GetConstructor() == obj) { 7214 if (map_of_this->GetConstructor() == obj) {
7206 return true; 7215 return true;
7207 } 7216 }
7208 7217
7209 // Is the object the prototype for this object? 7218 // Is the object the prototype for this object?
7210 if (map_of_this->prototype() == obj) { 7219 if (map_of_this->prototype() == obj) {
7211 return true; 7220 return true;
7212 } 7221 }
7213 7222
7214 // Check if the object is among the named properties. 7223 // Check if the object is among the named properties.
7215 Object* key = SlowReverseLookup(obj); 7224 Object* key = SlowReverseLookup(obj);
7216 if (!key->IsUndefined()) { 7225 if (!key->IsUndefined(heap->isolate())) {
7217 return true; 7226 return true;
7218 } 7227 }
7219 7228
7220 // Check if the object is among the indexed properties. 7229 // Check if the object is among the indexed properties.
7221 ElementsKind kind = GetElementsKind(); 7230 ElementsKind kind = GetElementsKind();
7222 switch (kind) { 7231 switch (kind) {
7223 // Raw pixels and external arrays do not reference other 7232 // Raw pixels and external arrays do not reference other
7224 // objects. 7233 // objects.
7225 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 7234 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
7226 case TYPE##_ELEMENTS: \ 7235 case TYPE##_ELEMENTS: \
(...skipping 17 matching lines...) Expand all
7244 if (ReferencesObjectFromElements(elements, kind, obj)) return true; 7253 if (ReferencesObjectFromElements(elements, kind, obj)) return true;
7245 break; 7254 break;
7246 } 7255 }
7247 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 7256 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
7248 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { 7257 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: {
7249 FixedArray* parameter_map = FixedArray::cast(elements()); 7258 FixedArray* parameter_map = FixedArray::cast(elements());
7250 // Check the mapped parameters. 7259 // Check the mapped parameters.
7251 int length = parameter_map->length(); 7260 int length = parameter_map->length();
7252 for (int i = 2; i < length; ++i) { 7261 for (int i = 2; i < length; ++i) {
7253 Object* value = parameter_map->get(i); 7262 Object* value = parameter_map->get(i);
7254 if (!value->IsTheHole() && value == obj) return true; 7263 if (!value->IsTheHole(heap->isolate()) && value == obj) return true;
7255 } 7264 }
7256 // Check the arguments. 7265 // Check the arguments.
7257 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); 7266 FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
7258 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : 7267 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS :
7259 FAST_HOLEY_ELEMENTS; 7268 FAST_HOLEY_ELEMENTS;
7260 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; 7269 if (ReferencesObjectFromElements(arguments, kind, obj)) return true;
7261 break; 7270 break;
7262 } 7271 }
7263 case NO_ELEMENTS: 7272 case NO_ELEMENTS:
7264 break; 7273 break;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
7431 isolate->Throw( 7440 isolate->Throw(
7432 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7441 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7433 return Nothing<bool>(); 7442 return Nothing<bool>();
7434 } 7443 }
7435 Handle<JSReceiver> target(proxy->target(), isolate); 7444 Handle<JSReceiver> target(proxy->target(), isolate);
7436 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7445 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7437 7446
7438 Handle<Object> trap; 7447 Handle<Object> trap;
7439 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7448 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7440 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 7449 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
7441 if (trap->IsUndefined()) { 7450 if (trap->IsUndefined(isolate)) {
7442 return JSReceiver::PreventExtensions(target, should_throw); 7451 return JSReceiver::PreventExtensions(target, should_throw);
7443 } 7452 }
7444 7453
7445 Handle<Object> trap_result; 7454 Handle<Object> trap_result;
7446 Handle<Object> args[] = {target}; 7455 Handle<Object> args[] = {target};
7447 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7456 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7448 isolate, trap_result, 7457 isolate, trap_result,
7449 Execution::Call(isolate, trap, handler, arraysize(args), args), 7458 Execution::Call(isolate, trap, handler, arraysize(args), args),
7450 Nothing<bool>()); 7459 Nothing<bool>());
7451 if (!trap_result->BooleanValue()) { 7460 if (!trap_result->BooleanValue()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7533 isolate->Throw( 7542 isolate->Throw(
7534 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7543 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7535 return Nothing<bool>(); 7544 return Nothing<bool>();
7536 } 7545 }
7537 Handle<JSReceiver> target(proxy->target(), isolate); 7546 Handle<JSReceiver> target(proxy->target(), isolate);
7538 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7547 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7539 7548
7540 Handle<Object> trap; 7549 Handle<Object> trap;
7541 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7550 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7542 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 7551 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
7543 if (trap->IsUndefined()) { 7552 if (trap->IsUndefined(isolate)) {
7544 return JSReceiver::IsExtensible(target); 7553 return JSReceiver::IsExtensible(target);
7545 } 7554 }
7546 7555
7547 Handle<Object> trap_result; 7556 Handle<Object> trap_result;
7548 Handle<Object> args[] = {target}; 7557 Handle<Object> args[] = {target};
7549 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7558 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7550 isolate, trap_result, 7559 isolate, trap_result,
7551 Execution::Call(isolate, trap, handler, arraysize(args), args), 7560 Execution::Call(isolate, trap, handler, arraysize(args), args),
7552 Nothing<bool>()); 7561 Nothing<bool>());
7553 7562
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
7985 } 7994 }
7986 7995
7987 // static 7996 // static
7988 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver, 7997 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver,
7989 ToPrimitiveHint hint) { 7998 ToPrimitiveHint hint) {
7990 Isolate* const isolate = receiver->GetIsolate(); 7999 Isolate* const isolate = receiver->GetIsolate();
7991 Handle<Object> exotic_to_prim; 8000 Handle<Object> exotic_to_prim;
7992 ASSIGN_RETURN_ON_EXCEPTION( 8001 ASSIGN_RETURN_ON_EXCEPTION(
7993 isolate, exotic_to_prim, 8002 isolate, exotic_to_prim,
7994 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object); 8003 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object);
7995 if (!exotic_to_prim->IsUndefined()) { 8004 if (!exotic_to_prim->IsUndefined(isolate)) {
7996 Handle<Object> hint_string; 8005 Handle<Object> hint_string;
7997 switch (hint) { 8006 switch (hint) {
7998 case ToPrimitiveHint::kDefault: 8007 case ToPrimitiveHint::kDefault:
7999 hint_string = isolate->factory()->default_string(); 8008 hint_string = isolate->factory()->default_string();
8000 break; 8009 break;
8001 case ToPrimitiveHint::kNumber: 8010 case ToPrimitiveHint::kNumber:
8002 hint_string = isolate->factory()->number_string(); 8011 hint_string = isolate->factory()->number_string();
8003 break; 8012 break;
8004 case ToPrimitiveHint::kString: 8013 case ToPrimitiveHint::kString:
8005 hint_string = isolate->factory()->string_string(); 8014 hint_string = isolate->factory()->string_string();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
8363 } 8372 }
8364 it->Next(); 8373 it->Next();
8365 } 8374 }
8366 8375
8367 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); 8376 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
8368 // Ignore accessors on typed arrays. 8377 // Ignore accessors on typed arrays.
8369 if (it->IsElement() && object->HasFixedTypedArrayElements()) { 8378 if (it->IsElement() && object->HasFixedTypedArrayElements()) {
8370 return it->factory()->undefined_value(); 8379 return it->factory()->undefined_value();
8371 } 8380 }
8372 8381
8373 DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull() || 8382 DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) ||
8374 getter->IsFunctionTemplateInfo()); 8383 getter->IsNull() || getter->IsFunctionTemplateInfo());
8375 DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() || 8384 DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) ||
8376 getter->IsFunctionTemplateInfo()); 8385 setter->IsNull() || getter->IsFunctionTemplateInfo());
8377 it->TransitionToAccessorProperty(getter, setter, attributes); 8386 it->TransitionToAccessorProperty(getter, setter, attributes);
8378 8387
8379 return isolate->factory()->undefined_value(); 8388 return isolate->factory()->undefined_value();
8380 } 8389 }
8381 8390
8382 8391
8383 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, 8392 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
8384 Handle<AccessorInfo> info) { 8393 Handle<AccessorInfo> info) {
8385 Isolate* isolate = object->GetIsolate(); 8394 Isolate* isolate = object->GetIsolate();
8386 Handle<Name> name(Name::cast(info->name()), isolate); 8395 Handle<Name> name(Name::cast(info->name()), isolate);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
8484 } 8493 }
8485 8494
8486 8495
8487 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, 8496 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode,
8488 const char* reason) { 8497 const char* reason) {
8489 DCHECK(!fast_map->is_dictionary_map()); 8498 DCHECK(!fast_map->is_dictionary_map());
8490 8499
8491 Isolate* isolate = fast_map->GetIsolate(); 8500 Isolate* isolate = fast_map->GetIsolate();
8492 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(), 8501 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
8493 isolate); 8502 isolate);
8494 bool use_cache = !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(); 8503 bool use_cache =
8504 !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(isolate);
8495 Handle<NormalizedMapCache> cache; 8505 Handle<NormalizedMapCache> cache;
8496 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache); 8506 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
8497 8507
8498 Handle<Map> new_map; 8508 Handle<Map> new_map;
8499 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) { 8509 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) {
8500 #ifdef VERIFY_HEAP 8510 #ifdef VERIFY_HEAP
8501 if (FLAG_verify_heap) new_map->DictionaryMapVerify(); 8511 if (FLAG_verify_heap) new_map->DictionaryMapVerify();
8502 #endif 8512 #endif
8503 #ifdef ENABLE_SLOW_DCHECKS 8513 #ifdef ENABLE_SLOW_DCHECKS
8504 if (FLAG_enable_slow_asserts) { 8514 if (FLAG_enable_slow_asserts) {
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
10017 return true; 10027 return true;
10018 } 10028 }
10019 10029
10020 10030
10021 // static 10031 // static
10022 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) { 10032 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) {
10023 if (name->IsString()) return Handle<String>::cast(name); 10033 if (name->IsString()) return Handle<String>::cast(name);
10024 // ES6 section 9.2.11 SetFunctionName, step 4. 10034 // ES6 section 9.2.11 SetFunctionName, step 4.
10025 Isolate* const isolate = name->GetIsolate(); 10035 Isolate* const isolate = name->GetIsolate();
10026 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate); 10036 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate);
10027 if (description->IsUndefined()) return isolate->factory()->empty_string(); 10037 if (description->IsUndefined(isolate)) {
10038 return isolate->factory()->empty_string();
10039 }
10028 IncrementalStringBuilder builder(isolate); 10040 IncrementalStringBuilder builder(isolate);
10029 builder.AppendCharacter('['); 10041 builder.AppendCharacter('[');
10030 builder.AppendString(Handle<String>::cast(description)); 10042 builder.AppendString(Handle<String>::cast(description));
10031 builder.AppendCharacter(']'); 10043 builder.AppendCharacter(']');
10032 return builder.Finish(); 10044 return builder.Finish();
10033 } 10045 }
10034 10046
10035 10047
10036 namespace { 10048 namespace {
10037 10049
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after
12399 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared()); 12411 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared());
12400 position = shared->abstract_code()->SourcePosition(-position); 12412 position = shared->abstract_code()->SourcePosition(-position);
12401 } 12413 }
12402 DCHECK(position >= 0); 12414 DCHECK(position >= 0);
12403 set_eval_from_position(position); 12415 set_eval_from_position(position);
12404 } 12416 }
12405 return position; 12417 return position;
12406 } 12418 }
12407 12419
12408 void Script::InitLineEnds(Handle<Script> script) { 12420 void Script::InitLineEnds(Handle<Script> script) {
12409 if (!script->line_ends()->IsUndefined()) return;
12410
12411 Isolate* isolate = script->GetIsolate(); 12421 Isolate* isolate = script->GetIsolate();
12422 if (!script->line_ends()->IsUndefined(isolate)) return;
12412 12423
12413 if (!script->source()->IsString()) { 12424 if (!script->source()->IsString()) {
12414 DCHECK(script->source()->IsUndefined()); 12425 DCHECK(script->source()->IsUndefined(isolate));
12415 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0); 12426 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0);
12416 script->set_line_ends(*empty); 12427 script->set_line_ends(*empty);
12417 DCHECK(script->line_ends()->IsFixedArray()); 12428 DCHECK(script->line_ends()->IsFixedArray());
12418 return; 12429 return;
12419 } 12430 }
12420 12431
12421 Handle<String> src(String::cast(script->source()), isolate); 12432 Handle<String> src(String::cast(script->source()), isolate);
12422 12433
12423 Handle<FixedArray> array = String::CalculateLineEnds(src, true); 12434 Handle<FixedArray> array = String::CalculateLineEnds(src, true);
12424 12435
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
12560 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL) 12571 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL)
12561 .ToHandle(&result)) { 12572 .ToHandle(&result)) {
12562 return isolate->factory()->undefined_value(); 12573 return isolate->factory()->undefined_value();
12563 } 12574 }
12564 return result; 12575 return result;
12565 } 12576 }
12566 12577
12567 12578
12568 Handle<JSObject> Script::GetWrapper(Handle<Script> script) { 12579 Handle<JSObject> Script::GetWrapper(Handle<Script> script) {
12569 Isolate* isolate = script->GetIsolate(); 12580 Isolate* isolate = script->GetIsolate();
12570 if (!script->wrapper()->IsUndefined()) { 12581 if (!script->wrapper()->IsUndefined(isolate)) {
12571 DCHECK(script->wrapper()->IsWeakCell()); 12582 DCHECK(script->wrapper()->IsWeakCell());
12572 Handle<WeakCell> cell(WeakCell::cast(script->wrapper())); 12583 Handle<WeakCell> cell(WeakCell::cast(script->wrapper()));
12573 if (!cell->cleared()) { 12584 if (!cell->cleared()) {
12574 // Return a handle for the existing script wrapper from the cache. 12585 // Return a handle for the existing script wrapper from the cache.
12575 return handle(JSObject::cast(cell->value())); 12586 return handle(JSObject::cast(cell->value()));
12576 } 12587 }
12577 // If we found an empty WeakCell, that means the script wrapper was 12588 // If we found an empty WeakCell, that means the script wrapper was
12578 // GCed. We are not notified directly of that, so we decrement here 12589 // GCed. We are not notified directly of that, so we decrement here
12579 // so that we at least don't count double for any given script. 12590 // so that we at least don't count double for any given script.
12580 isolate->counters()->script_wrappers()->Decrement(); 12591 isolate->counters()->script_wrappers()->Decrement();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
12725 return true; 12736 return true;
12726 } 12737 }
12727 if (filter[filter.length() - 1] == '*' && 12738 if (filter[filter.length() - 1] == '*' &&
12728 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { 12739 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
12729 return true; 12740 return true;
12730 } 12741 }
12731 return false; 12742 return false;
12732 } 12743 }
12733 12744
12734 bool SharedFunctionInfo::HasSourceCode() const { 12745 bool SharedFunctionInfo::HasSourceCode() const {
12735 return !script()->IsUndefined() && 12746 Isolate* isolate = GetIsolate();
12736 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); 12747 return !script()->IsUndefined(isolate) &&
12748 !reinterpret_cast<Script*>(script())->source()->IsUndefined(isolate);
12737 } 12749 }
12738 12750
12739 12751
12740 Handle<Object> SharedFunctionInfo::GetSourceCode() { 12752 Handle<Object> SharedFunctionInfo::GetSourceCode() {
12741 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); 12753 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value();
12742 Handle<String> source(String::cast(Script::cast(script())->source())); 12754 Handle<String> source(String::cast(Script::cast(script())->source()));
12743 return GetIsolate()->factory()->NewSubString( 12755 return GetIsolate()->factory()->NewSubString(
12744 source, start_position(), end_position()); 12756 source, start_position(), end_position());
12745 } 12757 }
12746 12758
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
14517 } 14529 }
14518 // 5. Let target be the value of the [[ProxyTarget]] internal slot. 14530 // 5. Let target be the value of the [[ProxyTarget]] internal slot.
14519 Handle<JSReceiver> target(proxy->target(), isolate); 14531 Handle<JSReceiver> target(proxy->target(), isolate);
14520 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). 14532 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf").
14521 Handle<Object> trap; 14533 Handle<Object> trap;
14522 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 14534 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
14523 isolate, trap, 14535 isolate, trap,
14524 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 14536 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
14525 Nothing<bool>()); 14537 Nothing<bool>());
14526 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). 14538 // 7. If trap is undefined, then return target.[[SetPrototypeOf]]().
14527 if (trap->IsUndefined()) { 14539 if (trap->IsUndefined(isolate)) {
14528 return JSReceiver::SetPrototype(target, value, from_javascript, 14540 return JSReceiver::SetPrototype(target, value, from_javascript,
14529 should_throw); 14541 should_throw);
14530 } 14542 }
14531 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). 14543 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)).
14532 Handle<Object> argv[] = {target, value}; 14544 Handle<Object> argv[] = {target, value};
14533 Handle<Object> trap_result; 14545 Handle<Object> trap_result;
14534 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 14546 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
14535 isolate, trap_result, 14547 isolate, trap_result,
14536 Execution::Call(isolate, trap, handler, arraysize(argv), argv), 14548 Execution::Call(isolate, trap, handler, arraysize(argv), argv),
14537 Nothing<bool>()); 14549 Nothing<bool>());
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
15160 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, 15172 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
15161 bool* done) { 15173 bool* done) {
15162 *done = false; 15174 *done = false;
15163 Isolate* isolate = it->isolate(); 15175 Isolate* isolate = it->isolate();
15164 // Make sure that the top context does not change when doing callbacks or 15176 // Make sure that the top context does not change when doing callbacks or
15165 // interceptor calls. 15177 // interceptor calls.
15166 AssertNoContextChange ncc(isolate); 15178 AssertNoContextChange ncc(isolate);
15167 15179
15168 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 15180 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
15169 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); 15181 Handle<InterceptorInfo> interceptor = it->GetInterceptor();
15170 if (interceptor->getter()->IsUndefined()) { 15182 if (interceptor->getter()->IsUndefined(isolate)) {
15171 return isolate->factory()->undefined_value(); 15183 return isolate->factory()->undefined_value();
15172 } 15184 }
15173 15185
15174 Handle<JSObject> holder = it->GetHolder<JSObject>(); 15186 Handle<JSObject> holder = it->GetHolder<JSObject>();
15175 Handle<Object> result; 15187 Handle<Object> result;
15176 Handle<Object> receiver = it->GetReceiver(); 15188 Handle<Object> receiver = it->GetReceiver();
15177 if (!receiver->IsJSReceiver()) { 15189 if (!receiver->IsJSReceiver()) {
15178 ASSIGN_RETURN_ON_EXCEPTION( 15190 ASSIGN_RETURN_ON_EXCEPTION(
15179 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object); 15191 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object);
15180 } 15192 }
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
15856 // 3. Detect a case when a dictionary key is not unique but the key is. 15868 // 3. Detect a case when a dictionary key is not unique but the key is.
15857 // In case of positive result the dictionary key may be replaced by the 15869 // In case of positive result the dictionary key may be replaced by the
15858 // internalized string with minimal performance penalty. It gives a chance 15870 // internalized string with minimal performance penalty. It gives a chance
15859 // to perform further lookups in code stubs (and significant performance 15871 // to perform further lookups in code stubs (and significant performance
15860 // boost a certain style of code). 15872 // boost a certain style of code).
15861 15873
15862 // EnsureCapacity will guarantee the hash table is never full. 15874 // EnsureCapacity will guarantee the hash table is never full.
15863 uint32_t capacity = this->Capacity(); 15875 uint32_t capacity = this->Capacity();
15864 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); 15876 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity);
15865 uint32_t count = 1; 15877 uint32_t count = 1;
15866 15878 Isolate* isolate = this->GetIsolate();
15867 while (true) { 15879 while (true) {
15868 int index = Derived::EntryToIndex(entry); 15880 int index = Derived::EntryToIndex(entry);
15869 Object* element = this->get(index); 15881 Object* element = this->get(index);
15870 if (element->IsUndefined()) break; // Empty entry. 15882 if (element->IsUndefined(isolate)) break; // Empty entry.
15871 if (*key == element) return entry; 15883 if (*key == element) return entry;
15872 if (!element->IsUniqueName() && 15884 if (!element->IsUniqueName() && !element->IsTheHole(isolate) &&
15873 !element->IsTheHole() &&
15874 Name::cast(element)->Equals(*key)) { 15885 Name::cast(element)->Equals(*key)) {
15875 // Replace a key that is a non-internalized string by the equivalent 15886 // Replace a key that is a non-internalized string by the equivalent
15876 // internalized string for faster further lookups. 15887 // internalized string for faster further lookups.
15877 this->set(index, *key); 15888 this->set(index, *key);
15878 return entry; 15889 return entry;
15879 } 15890 }
15880 DCHECK(element->IsTheHole() || !Name::cast(element)->Equals(*key)); 15891 DCHECK(element->IsTheHole(isolate) || !Name::cast(element)->Equals(*key));
15881 entry = Derived::NextProbe(entry, count++, capacity); 15892 entry = Derived::NextProbe(entry, count++, capacity);
15882 } 15893 }
15883 return Derived::kNotFound; 15894 return Derived::kNotFound;
15884 } 15895 }
15885 15896
15886 15897
15887 template<typename Derived, typename Shape, typename Key> 15898 template<typename Derived, typename Shape, typename Key>
15888 void HashTable<Derived, Shape, Key>::Rehash( 15899 void HashTable<Derived, Shape, Key>::Rehash(
15889 Handle<Derived> new_table, 15900 Handle<Derived> new_table,
15890 Key key) { 15901 Key key) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
16290 Handle<Object> value(dict->ValueAt(i), isolate); 16301 Handle<Object> value(dict->ValueAt(i), isolate);
16291 PropertyDetails details = dict->DetailsAt(i); 16302 PropertyDetails details = dict->DetailsAt(i);
16292 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) { 16303 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) {
16293 // Bail out and do the sorting of undefineds and array holes in JS. 16304 // Bail out and do the sorting of undefineds and array holes in JS.
16294 // Also bail out if the element is not supposed to be moved. 16305 // Also bail out if the element is not supposed to be moved.
16295 return bailout; 16306 return bailout;
16296 } 16307 }
16297 16308
16298 uint32_t key = NumberToUint32(k); 16309 uint32_t key = NumberToUint32(k);
16299 if (key < limit) { 16310 if (key < limit) {
16300 if (value->IsUndefined()) { 16311 if (value->IsUndefined(isolate)) {
16301 undefs++; 16312 undefs++;
16302 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { 16313 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) {
16303 // Adding an entry with the key beyond smi-range requires 16314 // Adding an entry with the key beyond smi-range requires
16304 // allocation. Bailout. 16315 // allocation. Bailout.
16305 return bailout; 16316 return bailout;
16306 } else { 16317 } else {
16307 Handle<Object> result = SeededNumberDictionary::AddNumberEntry( 16318 Handle<Object> result = SeededNumberDictionary::AddNumberEntry(
16308 new_dict, pos, value, details, object->map()->is_prototype_map()); 16319 new_dict, pos, value, details, object->map()->is_prototype_map());
16309 DCHECK(result.is_identical_to(new_dict)); 16320 DCHECK(result.is_identical_to(new_dict));
16310 USE(result); 16321 USE(result);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
16440 16451
16441 // Split elements into defined, undefined and the_hole, in that order. Only 16452 // Split elements into defined, undefined and the_hole, in that order. Only
16442 // count locations for undefined and the hole, and fill them afterwards. 16453 // count locations for undefined and the hole, and fill them afterwards.
16443 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc); 16454 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc);
16444 unsigned int undefs = limit; 16455 unsigned int undefs = limit;
16445 unsigned int holes = limit; 16456 unsigned int holes = limit;
16446 // Assume most arrays contain no holes and undefined values, so minimize the 16457 // Assume most arrays contain no holes and undefined values, so minimize the
16447 // number of stores of non-undefined, non-the-hole values. 16458 // number of stores of non-undefined, non-the-hole values.
16448 for (unsigned int i = 0; i < undefs; i++) { 16459 for (unsigned int i = 0; i < undefs; i++) {
16449 Object* current = elements->get(i); 16460 Object* current = elements->get(i);
16450 if (current->IsTheHole()) { 16461 if (current->IsTheHole(isolate)) {
16451 holes--; 16462 holes--;
16452 undefs--; 16463 undefs--;
16453 } else if (current->IsUndefined()) { 16464 } else if (current->IsUndefined(isolate)) {
16454 undefs--; 16465 undefs--;
16455 } else { 16466 } else {
16456 continue; 16467 continue;
16457 } 16468 }
16458 // Position i needs to be filled. 16469 // Position i needs to be filled.
16459 while (undefs > i) { 16470 while (undefs > i) {
16460 current = elements->get(undefs); 16471 current = elements->get(undefs);
16461 if (current->IsTheHole()) { 16472 if (current->IsTheHole(isolate)) {
16462 holes--; 16473 holes--;
16463 undefs--; 16474 undefs--;
16464 } else if (current->IsUndefined()) { 16475 } else if (current->IsUndefined(isolate)) {
16465 undefs--; 16476 undefs--;
16466 } else { 16477 } else {
16467 elements->set(i, current, write_barrier); 16478 elements->set(i, current, write_barrier);
16468 break; 16479 break;
16469 } 16480 }
16470 } 16481 }
16471 } 16482 }
16472 result = undefs; 16483 result = undefs;
16473 while (undefs < holes) { 16484 while (undefs < holes) {
16474 elements->set_undefined(undefs); 16485 elements->set_undefined(undefs);
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
17321 17332
17322 17333
17323 Object* ObjectHashTable::Lookup(Handle<Object> key) { 17334 Object* ObjectHashTable::Lookup(Handle<Object> key) {
17324 DisallowHeapAllocation no_gc; 17335 DisallowHeapAllocation no_gc;
17325 DCHECK(IsKey(*key)); 17336 DCHECK(IsKey(*key));
17326 17337
17327 Isolate* isolate = GetIsolate(); 17338 Isolate* isolate = GetIsolate();
17328 17339
17329 // If the object does not have an identity hash, it was never used as a key. 17340 // If the object does not have an identity hash, it was never used as a key.
17330 Object* hash = key->GetHash(); 17341 Object* hash = key->GetHash();
17331 if (hash->IsUndefined()) { 17342 if (hash->IsUndefined(isolate)) {
17332 return isolate->heap()->the_hole_value(); 17343 return isolate->heap()->the_hole_value();
17333 } 17344 }
17334 return Lookup(isolate, key, Smi::cast(hash)->value()); 17345 return Lookup(isolate, key, Smi::cast(hash)->value());
17335 } 17346 }
17336 17347
17337 17348
17338 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) { 17349 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) {
17339 return Lookup(GetIsolate(), key, hash); 17350 return Lookup(GetIsolate(), key, hash);
17340 } 17351 }
17341 17352
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
17721 } 17732 }
17722 17733
17723 set_table(table); 17734 set_table(table);
17724 set_index(Smi::FromInt(index)); 17735 set_index(Smi::FromInt(index));
17725 } 17736 }
17726 17737
17727 17738
17728 template<class Derived, class TableType> 17739 template<class Derived, class TableType>
17729 bool OrderedHashTableIterator<Derived, TableType>::HasMore() { 17740 bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
17730 DisallowHeapAllocation no_allocation; 17741 DisallowHeapAllocation no_allocation;
17731 if (this->table()->IsUndefined()) return false; 17742 Isolate* isolate = this->GetIsolate();
17743 if (this->table()->IsUndefined(isolate)) return false;
17732 17744
17733 Transition(); 17745 Transition();
17734 17746
17735 TableType* table = TableType::cast(this->table()); 17747 TableType* table = TableType::cast(this->table());
17736 int index = Smi::cast(this->index())->value(); 17748 int index = Smi::cast(this->index())->value();
17737 int used_capacity = table->UsedCapacity(); 17749 int used_capacity = table->UsedCapacity();
17738 17750
17739 while (index < used_capacity && table->KeyAt(index)->IsTheHole()) { 17751 while (index < used_capacity && table->KeyAt(index)->IsTheHole(isolate)) {
17740 index++; 17752 index++;
17741 } 17753 }
17742 17754
17743 set_index(Smi::FromInt(index)); 17755 set_index(Smi::FromInt(index));
17744 17756
17745 if (index < used_capacity) return true; 17757 if (index < used_capacity) return true;
17746 17758
17747 set_table(GetHeap()->undefined_value()); 17759 set_table(isolate->heap()->undefined_value());
17748 return false; 17760 return false;
17749 } 17761 }
17750 17762
17751 17763
17752 template<class Derived, class TableType> 17764 template<class Derived, class TableType>
17753 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { 17765 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) {
17754 DisallowHeapAllocation no_allocation; 17766 DisallowHeapAllocation no_allocation;
17755 if (HasMore()) { 17767 if (HasMore()) {
17756 FixedArray* array = FixedArray::cast(value_array->elements()); 17768 FixedArray* array = FixedArray::cast(value_array->elements());
17757 static_cast<Derived*>(this)->PopulateValueArray(array); 17769 static_cast<Derived*>(this)->PopulateValueArray(array);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
17894 Handle<BreakPointInfo>::cast(break_point_info), 17906 Handle<BreakPointInfo>::cast(break_point_info),
17895 break_point_object); 17907 break_point_object);
17896 } 17908 }
17897 17909
17898 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, 17910 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
17899 int source_position, int statement_position, 17911 int source_position, int statement_position,
17900 Handle<Object> break_point_object) { 17912 Handle<Object> break_point_object) {
17901 Isolate* isolate = debug_info->GetIsolate(); 17913 Isolate* isolate = debug_info->GetIsolate();
17902 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), 17914 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset),
17903 isolate); 17915 isolate);
17904 if (!break_point_info->IsUndefined()) { 17916 if (!break_point_info->IsUndefined(isolate)) {
17905 BreakPointInfo::SetBreakPoint( 17917 BreakPointInfo::SetBreakPoint(
17906 Handle<BreakPointInfo>::cast(break_point_info), 17918 Handle<BreakPointInfo>::cast(break_point_info),
17907 break_point_object); 17919 break_point_object);
17908 return; 17920 return;
17909 } 17921 }
17910 17922
17911 // Adding a new break point for a code offset which did not have any 17923 // Adding a new break point for a code offset which did not have any
17912 // break points before. Try to find a free slot. 17924 // break points before. Try to find a free slot.
17913 int index = kNoBreakPointInfo; 17925 int index = kNoBreakPointInfo;
17914 for (int i = 0; i < debug_info->break_points()->length(); i++) { 17926 for (int i = 0; i < debug_info->break_points()->length(); i++) {
17915 if (debug_info->break_points()->get(i)->IsUndefined()) { 17927 if (debug_info->break_points()->get(i)->IsUndefined(isolate)) {
17916 index = i; 17928 index = i;
17917 break; 17929 break;
17918 } 17930 }
17919 } 17931 }
17920 if (index == kNoBreakPointInfo) { 17932 if (index == kNoBreakPointInfo) {
17921 // No free slot - extend break point info array. 17933 // No free slot - extend break point info array.
17922 Handle<FixedArray> old_break_points = 17934 Handle<FixedArray> old_break_points =
17923 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); 17935 Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
17924 Handle<FixedArray> new_break_points = 17936 Handle<FixedArray> new_break_points =
17925 isolate->factory()->NewFixedArray( 17937 isolate->factory()->NewFixedArray(
(...skipping 16 matching lines...) Expand all
17942 new_break_point_info->set_statement_position(statement_position); 17954 new_break_point_info->set_statement_position(statement_position);
17943 new_break_point_info->set_break_point_objects( 17955 new_break_point_info->set_break_point_objects(
17944 isolate->heap()->undefined_value()); 17956 isolate->heap()->undefined_value());
17945 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); 17957 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
17946 debug_info->break_points()->set(index, *new_break_point_info); 17958 debug_info->break_points()->set(index, *new_break_point_info);
17947 } 17959 }
17948 17960
17949 // Get the break point objects for a code offset. 17961 // Get the break point objects for a code offset.
17950 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { 17962 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) {
17951 Object* break_point_info = GetBreakPointInfo(code_offset); 17963 Object* break_point_info = GetBreakPointInfo(code_offset);
17952 if (break_point_info->IsUndefined()) { 17964 Isolate* isolate = GetIsolate();
17953 return GetIsolate()->factory()->undefined_value(); 17965 if (break_point_info->IsUndefined(isolate)) {
17966 return isolate->factory()->undefined_value();
17954 } 17967 }
17955 return Handle<Object>( 17968 return Handle<Object>(
17956 BreakPointInfo::cast(break_point_info)->break_point_objects(), 17969 BreakPointInfo::cast(break_point_info)->break_point_objects(),
17957 GetIsolate()); 17970 GetIsolate());
17958 } 17971 }
17959 17972
17960 17973
17961 // Get the total number of break points. 17974 // Get the total number of break points.
17962 int DebugInfo::GetBreakPointCount() { 17975 int DebugInfo::GetBreakPointCount() {
17963 if (break_points()->IsUndefined()) return 0; 17976 Isolate* isolate = GetIsolate();
17977 if (break_points()->IsUndefined(isolate)) return 0;
17964 int count = 0; 17978 int count = 0;
17965 for (int i = 0; i < break_points()->length(); i++) { 17979 for (int i = 0; i < break_points()->length(); i++) {
17966 if (!break_points()->get(i)->IsUndefined()) { 17980 if (!break_points()->get(i)->IsUndefined(isolate)) {
17967 BreakPointInfo* break_point_info = 17981 BreakPointInfo* break_point_info =
17968 BreakPointInfo::cast(break_points()->get(i)); 17982 BreakPointInfo::cast(break_points()->get(i));
17969 count += break_point_info->GetBreakPointCount(); 17983 count += break_point_info->GetBreakPointCount();
17970 } 17984 }
17971 } 17985 }
17972 return count; 17986 return count;
17973 } 17987 }
17974 17988
17975 17989
17976 Handle<Object> DebugInfo::FindBreakPointInfo( 17990 Handle<Object> DebugInfo::FindBreakPointInfo(
17977 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) { 17991 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) {
17978 Isolate* isolate = debug_info->GetIsolate(); 17992 Isolate* isolate = debug_info->GetIsolate();
17979 if (!debug_info->break_points()->IsUndefined()) { 17993 if (!debug_info->break_points()->IsUndefined(isolate)) {
17980 for (int i = 0; i < debug_info->break_points()->length(); i++) { 17994 for (int i = 0; i < debug_info->break_points()->length(); i++) {
17981 if (!debug_info->break_points()->get(i)->IsUndefined()) { 17995 if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) {
17982 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>( 17996 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>(
17983 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate); 17997 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate);
17984 if (BreakPointInfo::HasBreakPointObject(break_point_info, 17998 if (BreakPointInfo::HasBreakPointObject(break_point_info,
17985 break_point_object)) { 17999 break_point_object)) {
17986 return break_point_info; 18000 return break_point_info;
17987 } 18001 }
17988 } 18002 }
17989 } 18003 }
17990 } 18004 }
17991 return isolate->factory()->undefined_value(); 18005 return isolate->factory()->undefined_value();
17992 } 18006 }
17993 18007
17994 18008
17995 // Find the index of the break point info object for the specified code 18009 // Find the index of the break point info object for the specified code
17996 // position. 18010 // position.
17997 int DebugInfo::GetBreakPointInfoIndex(int code_offset) { 18011 int DebugInfo::GetBreakPointInfoIndex(int code_offset) {
17998 if (break_points()->IsUndefined()) return kNoBreakPointInfo; 18012 Isolate* isolate = GetIsolate();
18013 if (break_points()->IsUndefined(isolate)) return kNoBreakPointInfo;
17999 for (int i = 0; i < break_points()->length(); i++) { 18014 for (int i = 0; i < break_points()->length(); i++) {
18000 if (!break_points()->get(i)->IsUndefined()) { 18015 if (!break_points()->get(i)->IsUndefined(isolate)) {
18001 BreakPointInfo* break_point_info = 18016 BreakPointInfo* break_point_info =
18002 BreakPointInfo::cast(break_points()->get(i)); 18017 BreakPointInfo::cast(break_points()->get(i));
18003 if (break_point_info->code_offset() == code_offset) { 18018 if (break_point_info->code_offset() == code_offset) {
18004 return i; 18019 return i;
18005 } 18020 }
18006 } 18021 }
18007 } 18022 }
18008 return kNoBreakPointInfo; 18023 return kNoBreakPointInfo;
18009 } 18024 }
18010 18025
18011 18026
18012 // Remove the specified break point object. 18027 // Remove the specified break point object.
18013 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, 18028 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
18014 Handle<Object> break_point_object) { 18029 Handle<Object> break_point_object) {
18015 Isolate* isolate = break_point_info->GetIsolate(); 18030 Isolate* isolate = break_point_info->GetIsolate();
18016 // If there are no break points just ignore. 18031 // If there are no break points just ignore.
18017 if (break_point_info->break_point_objects()->IsUndefined()) return; 18032 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return;
18018 // If there is a single break point clear it if it is the same. 18033 // If there is a single break point clear it if it is the same.
18019 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18034 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18020 if (break_point_info->break_point_objects() == *break_point_object) { 18035 if (break_point_info->break_point_objects() == *break_point_object) {
18021 break_point_info->set_break_point_objects( 18036 break_point_info->set_break_point_objects(
18022 isolate->heap()->undefined_value()); 18037 isolate->heap()->undefined_value());
18023 } 18038 }
18024 return; 18039 return;
18025 } 18040 }
18026 // If there are multiple break points shrink the array 18041 // If there are multiple break points shrink the array
18027 DCHECK(break_point_info->break_point_objects()->IsFixedArray()); 18042 DCHECK(break_point_info->break_point_objects()->IsFixedArray());
(...skipping 15 matching lines...) Expand all
18043 if (found_count > 0) break_point_info->set_break_point_objects(*new_array); 18058 if (found_count > 0) break_point_info->set_break_point_objects(*new_array);
18044 } 18059 }
18045 18060
18046 18061
18047 // Add the specified break point object. 18062 // Add the specified break point object.
18048 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info, 18063 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
18049 Handle<Object> break_point_object) { 18064 Handle<Object> break_point_object) {
18050 Isolate* isolate = break_point_info->GetIsolate(); 18065 Isolate* isolate = break_point_info->GetIsolate();
18051 18066
18052 // If there was no break point objects before just set it. 18067 // If there was no break point objects before just set it.
18053 if (break_point_info->break_point_objects()->IsUndefined()) { 18068 if (break_point_info->break_point_objects()->IsUndefined(isolate)) {
18054 break_point_info->set_break_point_objects(*break_point_object); 18069 break_point_info->set_break_point_objects(*break_point_object);
18055 return; 18070 return;
18056 } 18071 }
18057 // If the break point object is the same as before just ignore. 18072 // If the break point object is the same as before just ignore.
18058 if (break_point_info->break_point_objects() == *break_point_object) return; 18073 if (break_point_info->break_point_objects() == *break_point_object) return;
18059 // If there was one break point object before replace with array. 18074 // If there was one break point object before replace with array.
18060 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18075 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18061 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2); 18076 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2);
18062 array->set(0, break_point_info->break_point_objects()); 18077 array->set(0, break_point_info->break_point_objects());
18063 array->set(1, *break_point_object); 18078 array->set(1, *break_point_object);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
18424 18439
18425 Handle<PropertyCell> PropertyCell::InvalidateEntry( 18440 Handle<PropertyCell> PropertyCell::InvalidateEntry(
18426 Handle<GlobalDictionary> dictionary, int entry) { 18441 Handle<GlobalDictionary> dictionary, int entry) {
18427 Isolate* isolate = dictionary->GetIsolate(); 18442 Isolate* isolate = dictionary->GetIsolate();
18428 // Swap with a copy. 18443 // Swap with a copy.
18429 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); 18444 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
18430 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); 18445 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
18431 auto new_cell = isolate->factory()->NewPropertyCell(); 18446 auto new_cell = isolate->factory()->NewPropertyCell();
18432 new_cell->set_value(cell->value()); 18447 new_cell->set_value(cell->value());
18433 dictionary->ValueAtPut(entry, *new_cell); 18448 dictionary->ValueAtPut(entry, *new_cell);
18434 bool is_the_hole = cell->value()->IsTheHole(); 18449 bool is_the_hole = cell->value()->IsTheHole(isolate);
18435 // Cell is officially mutable henceforth. 18450 // Cell is officially mutable henceforth.
18436 PropertyDetails details = cell->property_details(); 18451 PropertyDetails details = cell->property_details();
18437 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated 18452 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated
18438 : PropertyCellType::kMutable); 18453 : PropertyCellType::kMutable);
18439 new_cell->set_property_details(details); 18454 new_cell->set_property_details(details);
18440 // Old cell is ready for invalidation. 18455 // Old cell is ready for invalidation.
18441 if (is_the_hole) { 18456 if (is_the_hole) {
18442 cell->set_value(isolate->heap()->undefined_value()); 18457 cell->set_value(isolate->heap()->undefined_value());
18443 } else { 18458 } else {
18444 cell->set_value(isolate->heap()->the_hole_value()); 18459 cell->set_value(isolate->heap()->the_hole_value());
(...skipping 23 matching lines...) Expand all
18468 HeapObject::cast(*value)->map()->is_stable(); 18483 HeapObject::cast(*value)->map()->is_stable();
18469 } 18484 }
18470 return false; 18485 return false;
18471 } 18486 }
18472 18487
18473 18488
18474 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell, 18489 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
18475 Handle<Object> value, 18490 Handle<Object> value,
18476 PropertyDetails details) { 18491 PropertyDetails details) {
18477 PropertyCellType type = details.cell_type(); 18492 PropertyCellType type = details.cell_type();
18478 DCHECK(!value->IsTheHole()); 18493 Isolate* isolate = cell->GetIsolate();
18479 if (cell->value()->IsTheHole()) { 18494 DCHECK(!value->IsTheHole(isolate));
18495 if (cell->value()->IsTheHole(isolate)) {
18480 switch (type) { 18496 switch (type) {
18481 // Only allow a cell to transition once into constant state. 18497 // Only allow a cell to transition once into constant state.
18482 case PropertyCellType::kUninitialized: 18498 case PropertyCellType::kUninitialized:
18483 if (value->IsUndefined()) return PropertyCellType::kUndefined; 18499 if (value->IsUndefined(isolate)) return PropertyCellType::kUndefined;
18484 return PropertyCellType::kConstant; 18500 return PropertyCellType::kConstant;
18485 case PropertyCellType::kInvalidated: 18501 case PropertyCellType::kInvalidated:
18486 return PropertyCellType::kMutable; 18502 return PropertyCellType::kMutable;
18487 default: 18503 default:
18488 UNREACHABLE(); 18504 UNREACHABLE();
18489 return PropertyCellType::kMutable; 18505 return PropertyCellType::kMutable;
18490 } 18506 }
18491 } 18507 }
18492 switch (type) { 18508 switch (type) {
18493 case PropertyCellType::kUndefined: 18509 case PropertyCellType::kUndefined:
18494 return PropertyCellType::kConstant; 18510 return PropertyCellType::kConstant;
18495 case PropertyCellType::kConstant: 18511 case PropertyCellType::kConstant:
18496 if (*value == cell->value()) return PropertyCellType::kConstant; 18512 if (*value == cell->value()) return PropertyCellType::kConstant;
18497 // Fall through. 18513 // Fall through.
18498 case PropertyCellType::kConstantType: 18514 case PropertyCellType::kConstantType:
18499 if (RemainsConstantType(cell, value)) { 18515 if (RemainsConstantType(cell, value)) {
18500 return PropertyCellType::kConstantType; 18516 return PropertyCellType::kConstantType;
18501 } 18517 }
18502 // Fall through. 18518 // Fall through.
18503 case PropertyCellType::kMutable: 18519 case PropertyCellType::kMutable:
18504 return PropertyCellType::kMutable; 18520 return PropertyCellType::kMutable;
18505 } 18521 }
18506 UNREACHABLE(); 18522 UNREACHABLE();
18507 return PropertyCellType::kMutable; 18523 return PropertyCellType::kMutable;
18508 } 18524 }
18509 18525
18510 18526
18511 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, 18527 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry,
18512 Handle<Object> value, PropertyDetails details) { 18528 Handle<Object> value, PropertyDetails details) {
18513 DCHECK(!value->IsTheHole()); 18529 Isolate* isolate = dictionary->GetIsolate();
18530 DCHECK(!value->IsTheHole(isolate));
18514 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); 18531 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
18515 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); 18532 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
18516 const PropertyDetails original_details = cell->property_details(); 18533 const PropertyDetails original_details = cell->property_details();
18517 // Data accesses could be cached in ics or optimized code. 18534 // Data accesses could be cached in ics or optimized code.
18518 bool invalidate = 18535 bool invalidate =
18519 original_details.kind() == kData && details.kind() == kAccessor; 18536 original_details.kind() == kData && details.kind() == kAccessor;
18520 int index = original_details.dictionary_index(); 18537 int index = original_details.dictionary_index();
18521 PropertyCellType old_type = original_details.cell_type(); 18538 PropertyCellType old_type = original_details.cell_type();
18522 // Preserve the enumeration index unless the property was deleted or never 18539 // Preserve the enumeration index unless the property was deleted or never
18523 // initialized. 18540 // initialized.
18524 if (cell->value()->IsTheHole()) { 18541 if (cell->value()->IsTheHole(isolate)) {
18525 index = dictionary->NextEnumerationIndex(); 18542 index = dictionary->NextEnumerationIndex();
18526 dictionary->SetNextEnumerationIndex(index + 1); 18543 dictionary->SetNextEnumerationIndex(index + 1);
18527 // Negative lookup cells must be invalidated. 18544 // Negative lookup cells must be invalidated.
18528 invalidate = true; 18545 invalidate = true;
18529 } 18546 }
18530 DCHECK(index > 0); 18547 DCHECK(index > 0);
18531 details = details.set_index(index); 18548 details = details.set_index(index);
18532 18549
18533 PropertyCellType new_type = UpdatedType(cell, value, original_details); 18550 PropertyCellType new_type = UpdatedType(cell, value, original_details);
18534 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); 18551 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry);
18535 18552
18536 // Install new property details and cell value. 18553 // Install new property details and cell value.
18537 details = details.set_cell_type(new_type); 18554 details = details.set_cell_type(new_type);
18538 cell->set_property_details(details); 18555 cell->set_property_details(details);
18539 cell->set_value(*value); 18556 cell->set_value(*value);
18540 18557
18541 // Deopt when transitioning from a constant type. 18558 // Deopt when transitioning from a constant type.
18542 if (!invalidate && (old_type != new_type || 18559 if (!invalidate && (old_type != new_type ||
18543 original_details.IsReadOnly() != details.IsReadOnly())) { 18560 original_details.IsReadOnly() != details.IsReadOnly())) {
18544 Isolate* isolate = dictionary->GetIsolate();
18545 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18561 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18546 isolate, DependentCode::kPropertyCellChangedGroup); 18562 isolate, DependentCode::kPropertyCellChangedGroup);
18547 } 18563 }
18548 } 18564 }
18549 18565
18550 18566
18551 // static 18567 // static
18552 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, 18568 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell,
18553 Handle<Object> new_value) { 18569 Handle<Object> new_value) {
18554 if (cell->value() != *new_value) { 18570 if (cell->value() != *new_value) {
18555 cell->set_value(*new_value); 18571 cell->set_value(*new_value);
18556 Isolate* isolate = cell->GetIsolate(); 18572 Isolate* isolate = cell->GetIsolate();
18557 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18573 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18558 isolate, DependentCode::kPropertyCellChangedGroup); 18574 isolate, DependentCode::kPropertyCellChangedGroup);
18559 } 18575 }
18560 } 18576 }
18561 18577
18562 } // namespace internal 18578 } // namespace internal
18563 } // namespace v8 18579 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698