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

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: reducing old cmpare patterns 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Handle<JSValue>::cast(result)->set_value(*object); 117 Handle<JSValue>::cast(result)->set_value(*object);
118 return result; 118 return result;
119 } 119 }
120 120
121 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. 121 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee.
122 // static 122 // static
123 MaybeHandle<JSReceiver> Object::ConvertReceiver(Isolate* isolate, 123 MaybeHandle<JSReceiver> Object::ConvertReceiver(Isolate* isolate,
124 Handle<Object> object) { 124 Handle<Object> object) {
125 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); 125 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
126 if (*object == isolate->heap()->null_value() || 126 if (*object == isolate->heap()->null_value() ||
127 *object == isolate->heap()->undefined_value()) { 127 object->IsUndefined(isolate)) {
128 return isolate->global_proxy(); 128 return isolate->global_proxy();
129 } 129 }
130 return Object::ToObject(isolate, object); 130 return Object::ToObject(isolate, object);
131 } 131 }
132 132
133 // static 133 // static
134 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) { 134 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
135 while (true) { 135 while (true) {
136 if (input->IsNumber()) { 136 if (input->IsNumber()) {
137 return input; 137 return input;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 if (len <= 0.0) { 224 if (len <= 0.0) {
225 len = 0.0; 225 len = 0.0;
226 } else if (len >= kMaxSafeInteger) { 226 } else if (len >= kMaxSafeInteger) {
227 len = kMaxSafeInteger; 227 len = kMaxSafeInteger;
228 } 228 }
229 return isolate->factory()->NewNumber(len); 229 return isolate->factory()->NewNumber(len);
230 } 230 }
231 231
232 232
233 bool Object::BooleanValue() { 233 bool Object::BooleanValue() {
234 if (IsSmi()) return Smi::cast(this)->value() != 0;
234 if (IsBoolean()) return IsTrue(); 235 if (IsBoolean()) return IsTrue();
235 if (IsSmi()) return Smi::cast(this)->value() != 0; 236 DCHECK(IsHeapObject());
236 if (IsUndefined() || IsNull()) return false; 237 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
238 if (IsUndefined(isolate) || IsNull()) return false;
237 if (IsUndetectable()) return false; // Undetectable object is false. 239 if (IsUndetectable()) return false; // Undetectable object is false.
238 if (IsString()) return String::cast(this)->length() != 0; 240 if (IsString()) return String::cast(this)->length() != 0;
239 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); 241 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue();
240 return true; 242 return true;
241 } 243 }
242 244
243 245
244 namespace { 246 namespace {
245 247
246 // TODO(bmeurer): Maybe we should introduce a marker interface Number, 248 // TODO(bmeurer): Maybe we should introduce a marker interface Number,
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 Object); 623 Object);
622 } 624 }
623 625
624 // Lookup the @@hasInstance method on {callable}. 626 // Lookup the @@hasInstance method on {callable}.
625 Handle<Object> inst_of_handler; 627 Handle<Object> inst_of_handler;
626 ASSIGN_RETURN_ON_EXCEPTION( 628 ASSIGN_RETURN_ON_EXCEPTION(
627 isolate, inst_of_handler, 629 isolate, inst_of_handler,
628 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable), 630 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable),
629 isolate->factory()->has_instance_symbol()), 631 isolate->factory()->has_instance_symbol()),
630 Object); 632 Object);
631 if (!inst_of_handler->IsUndefined()) { 633 if (!inst_of_handler->IsUndefined(isolate)) {
632 // Call the {inst_of_handler} on the {callable}. 634 // Call the {inst_of_handler} on the {callable}.
633 Handle<Object> result; 635 Handle<Object> result;
634 ASSIGN_RETURN_ON_EXCEPTION( 636 ASSIGN_RETURN_ON_EXCEPTION(
635 isolate, result, 637 isolate, result,
636 Execution::Call(isolate, inst_of_handler, callable, 1, &object), 638 Execution::Call(isolate, inst_of_handler, callable, 1, &object),
637 Object); 639 Object);
638 return isolate->factory()->ToBoolean(result->BooleanValue()); 640 return isolate->factory()->ToBoolean(result->BooleanValue());
639 } 641 }
640 } 642 }
641 643
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 687 }
686 688
687 689
688 // static 690 // static
689 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver, 691 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver,
690 Handle<Name> name) { 692 Handle<Name> name) {
691 Handle<Object> func; 693 Handle<Object> func;
692 Isolate* isolate = receiver->GetIsolate(); 694 Isolate* isolate = receiver->GetIsolate();
693 ASSIGN_RETURN_ON_EXCEPTION(isolate, func, 695 ASSIGN_RETURN_ON_EXCEPTION(isolate, func,
694 JSReceiver::GetProperty(receiver, name), Object); 696 JSReceiver::GetProperty(receiver, name), Object);
695 if (func->IsNull() || func->IsUndefined()) { 697 if (func->IsNull() || func->IsUndefined(isolate)) {
696 return isolate->factory()->undefined_value(); 698 return isolate->factory()->undefined_value();
697 } 699 }
698 if (!func->IsCallable()) { 700 if (!func->IsCallable()) {
699 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction, 701 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction,
700 func, name, receiver), 702 func, name, receiver),
701 Object); 703 Object);
702 } 704 }
703 return func; 705 return func;
704 } 706 }
705 707
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 Object); 882 Object);
881 } 883 }
882 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 884 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
883 Handle<JSReceiver> target(proxy->target(), isolate); 885 Handle<JSReceiver> target(proxy->target(), isolate);
884 // 6. Let trap be ? GetMethod(handler, "get"). 886 // 6. Let trap be ? GetMethod(handler, "get").
885 Handle<Object> trap; 887 Handle<Object> trap;
886 ASSIGN_RETURN_ON_EXCEPTION( 888 ASSIGN_RETURN_ON_EXCEPTION(
887 isolate, trap, 889 isolate, trap,
888 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object); 890 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object);
889 // 7. If trap is undefined, then 891 // 7. If trap is undefined, then
890 if (trap->IsUndefined()) { 892 if (trap->IsUndefined(isolate)) {
891 // 7.a Return target.[[Get]](P, Receiver). 893 // 7.a Return target.[[Get]](P, Receiver).
892 LookupIterator it = 894 LookupIterator it =
893 LookupIterator::PropertyOrElement(isolate, receiver, name, target); 895 LookupIterator::PropertyOrElement(isolate, receiver, name, target);
894 MaybeHandle<Object> result = Object::GetProperty(&it); 896 MaybeHandle<Object> result = Object::GetProperty(&it);
895 *was_found = it.IsFound(); 897 *was_found = it.IsFound();
896 return result; 898 return result;
897 } 899 }
898 // 8. Let trapResult be ? Call(trap, handler, «target, P, Receiver»). 900 // 8. Let trapResult be ? Call(trap, handler, «target, P, Receiver»).
899 Handle<Object> trap_result; 901 Handle<Object> trap_result;
900 Handle<Object> args[] = {target, name, receiver}; 902 Handle<Object> args[] = {target, name, receiver};
(...skipping 19 matching lines...) Expand all
920 THROW_NEW_ERROR( 922 THROW_NEW_ERROR(
921 isolate, NewTypeError(MessageTemplate::kProxyGetNonConfigurableData, 923 isolate, NewTypeError(MessageTemplate::kProxyGetNonConfigurableData,
922 name, target_desc.value(), trap_result), 924 name, target_desc.value(), trap_result),
923 Object); 925 Object);
924 } 926 }
925 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]] 927 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]]
926 // is false and targetDesc.[[Get]] is undefined, then 928 // is false and targetDesc.[[Get]] is undefined, then
927 // 10.b.i. If trapResult is not undefined, throw a TypeError exception. 929 // 10.b.i. If trapResult is not undefined, throw a TypeError exception.
928 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && 930 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
929 !target_desc.configurable() && 931 !target_desc.configurable() &&
930 target_desc.get()->IsUndefined() && 932 target_desc.get()->IsUndefined(isolate) &&
931 !trap_result->IsUndefined(); 933 !trap_result->IsUndefined(isolate);
932 if (inconsistent) { 934 if (inconsistent) {
933 THROW_NEW_ERROR( 935 THROW_NEW_ERROR(
934 isolate, 936 isolate,
935 NewTypeError(MessageTemplate::kProxyGetNonConfigurableAccessor, name, 937 NewTypeError(MessageTemplate::kProxyGetNonConfigurableAccessor, name,
936 trap_result), 938 trap_result),
937 Object); 939 Object);
938 } 940 }
939 } 941 }
940 // 11. Return trap_result 942 // 11. Return trap_result
941 return trap_result; 943 return trap_result;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 } 1015 }
1014 1016
1015 1017
1016 // TODO(dcarney): CallOptimization duplicates this logic, merge. 1018 // TODO(dcarney): CallOptimization duplicates this logic, merge.
1017 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate, 1019 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate,
1018 Object* receiver) { 1020 Object* receiver) {
1019 // API calls are only supported with JSObject receivers. 1021 // API calls are only supported with JSObject receivers.
1020 if (!receiver->IsJSObject()) return isolate->heap()->null_value(); 1022 if (!receiver->IsJSObject()) return isolate->heap()->null_value();
1021 Object* recv_type = this->signature(); 1023 Object* recv_type = this->signature();
1022 // No signature, return holder. 1024 // No signature, return holder.
1023 if (recv_type->IsUndefined()) return receiver; 1025 if (recv_type->IsUndefined(isolate)) return receiver;
1024 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type); 1026 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
1025 // Check the receiver. 1027 // Check the receiver.
1026 for (PrototypeIterator iter(isolate, JSObject::cast(receiver), 1028 for (PrototypeIterator iter(isolate, JSObject::cast(receiver),
1027 PrototypeIterator::START_AT_RECEIVER, 1029 PrototypeIterator::START_AT_RECEIVER,
1028 PrototypeIterator::END_AT_NON_HIDDEN); 1030 PrototypeIterator::END_AT_NON_HIDDEN);
1029 !iter.IsAtEnd(); iter.Advance()) { 1031 !iter.IsAtEnd(); iter.Advance()) {
1030 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent(); 1032 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent();
1031 } 1033 }
1032 return isolate->heap()->null_value(); 1034 return isolate->heap()->null_value();
1033 } 1035 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 Object); 1094 Object);
1093 } 1095 }
1094 Handle<JSReceiver> target(proxy->target(), isolate); 1096 Handle<JSReceiver> target(proxy->target(), isolate);
1095 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 1097 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
1096 1098
1097 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf"). 1099 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf").
1098 Handle<Object> trap; 1100 Handle<Object> trap;
1099 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name), 1101 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name),
1100 Object); 1102 Object);
1101 // 6. If trap is undefined, then return target.[[GetPrototypeOf]](). 1103 // 6. If trap is undefined, then return target.[[GetPrototypeOf]]().
1102 if (trap->IsUndefined()) { 1104 if (trap->IsUndefined(isolate)) {
1103 return JSReceiver::GetPrototype(isolate, target); 1105 return JSReceiver::GetPrototype(isolate, target);
1104 } 1106 }
1105 // 7. Let handlerProto be ? Call(trap, handler, «target»). 1107 // 7. Let handlerProto be ? Call(trap, handler, «target»).
1106 Handle<Object> argv[] = {target}; 1108 Handle<Object> argv[] = {target};
1107 Handle<Object> handler_proto; 1109 Handle<Object> handler_proto;
1108 ASSIGN_RETURN_ON_EXCEPTION( 1110 ASSIGN_RETURN_ON_EXCEPTION(
1109 isolate, handler_proto, 1111 isolate, handler_proto,
1110 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object); 1112 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object);
1111 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError. 1113 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError.
1112 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) { 1114 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (!name->IsUniqueName()) { 1441 if (!name->IsUniqueName()) {
1440 name = object->GetIsolate()->factory()->InternalizeString( 1442 name = object->GetIsolate()->factory()->InternalizeString(
1441 Handle<String>::cast(name)); 1443 Handle<String>::cast(name));
1442 } 1444 }
1443 1445
1444 if (object->IsJSGlobalObject()) { 1446 if (object->IsJSGlobalObject()) {
1445 Handle<GlobalDictionary> property_dictionary(object->global_dictionary()); 1447 Handle<GlobalDictionary> property_dictionary(object->global_dictionary());
1446 1448
1447 int entry = property_dictionary->FindEntry(name); 1449 int entry = property_dictionary->FindEntry(name);
1448 if (entry == GlobalDictionary::kNotFound) { 1450 if (entry == GlobalDictionary::kNotFound) {
1449 auto cell = object->GetIsolate()->factory()->NewPropertyCell(); 1451 Isolate* isolate = object->GetIsolate();
1452 auto cell = isolate->factory()->NewPropertyCell();
1450 cell->set_value(*value); 1453 cell->set_value(*value);
1451 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined 1454 auto cell_type = value->IsUndefined(isolate)
1452 : PropertyCellType::kConstant; 1455 ? PropertyCellType::kUndefined
1456 : PropertyCellType::kConstant;
1453 details = details.set_cell_type(cell_type); 1457 details = details.set_cell_type(cell_type);
1454 value = cell; 1458 value = cell;
1455 property_dictionary = 1459 property_dictionary =
1456 GlobalDictionary::Add(property_dictionary, name, value, details); 1460 GlobalDictionary::Add(property_dictionary, name, value, details);
1457 object->set_properties(*property_dictionary); 1461 object->set_properties(*property_dictionary);
1458 } else { 1462 } else {
1459 PropertyCell::UpdateCell(property_dictionary, entry, value, details); 1463 PropertyCell::UpdateCell(property_dictionary, entry, value, details);
1460 } 1464 }
1461 } else { 1465 } else {
1462 Handle<NameDictionary> property_dictionary(object->property_dictionary()); 1466 Handle<NameDictionary> property_dictionary(object->property_dictionary());
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 ASSIGN_RETURN_ON_EXCEPTION( 1685 ASSIGN_RETURN_ON_EXCEPTION(
1682 isolate, constructor, 1686 isolate, constructor,
1683 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor), 1687 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor),
1684 isolate->factory()->species_symbol()), 1688 isolate->factory()->species_symbol()),
1685 Object); 1689 Object);
1686 if (constructor->IsNull()) { 1690 if (constructor->IsNull()) {
1687 constructor = isolate->factory()->undefined_value(); 1691 constructor = isolate->factory()->undefined_value();
1688 } 1692 }
1689 } 1693 }
1690 } 1694 }
1691 if (constructor->IsUndefined()) { 1695 if (constructor->IsUndefined(isolate)) {
1692 return default_species; 1696 return default_species;
1693 } else { 1697 } else {
1694 if (!constructor->IsConstructor()) { 1698 if (!constructor->IsConstructor()) {
1695 THROW_NEW_ERROR(isolate, 1699 THROW_NEW_ERROR(isolate,
1696 NewTypeError(MessageTemplate::kSpeciesNotConstructor), 1700 NewTypeError(MessageTemplate::kSpeciesNotConstructor),
1697 Object); 1701 Object);
1698 } 1702 }
1699 return constructor; 1703 return constructor;
1700 } 1704 }
1701 } 1705 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 StringCharacterStream stream(this, start); 1985 StringCharacterStream stream(this, start);
1982 for (int i = start; i < end && stream.HasMore(); i++) { 1986 for (int i = start; i < end && stream.HasMore(); i++) {
1983 os << AsUC16(stream.GetNext()); 1987 os << AsUC16(stream.GetNext());
1984 } 1988 }
1985 } 1989 }
1986 1990
1987 1991
1988 void JSObject::JSObjectShortPrint(StringStream* accumulator) { 1992 void JSObject::JSObjectShortPrint(StringStream* accumulator) {
1989 switch (map()->instance_type()) { 1993 switch (map()->instance_type()) {
1990 case JS_ARRAY_TYPE: { 1994 case JS_ARRAY_TYPE: {
1991 double length = JSArray::cast(this)->length()->IsUndefined() 1995 double length = JSArray::cast(this)->length()->IsUndefined(GetIsolate())
1992 ? 0 1996 ? 0
1993 : JSArray::cast(this)->length()->Number(); 1997 : JSArray::cast(this)->length()->Number();
1994 accumulator->Add("<JS Array[%u]>", static_cast<uint32_t>(length)); 1998 accumulator->Add("<JS Array[%u]>", static_cast<uint32_t>(length));
1995 break; 1999 break;
1996 } 2000 }
1997 case JS_BOUND_FUNCTION_TYPE: { 2001 case JS_BOUND_FUNCTION_TYPE: {
1998 JSBoundFunction* bound_function = JSBoundFunction::cast(this); 2002 JSBoundFunction* bound_function = JSBoundFunction::cast(this);
1999 accumulator->Add("<JS BoundFunction"); 2003 accumulator->Add("<JS BoundFunction");
2000 accumulator->Add( 2004 accumulator->Add(
2001 " (BoundTargetFunction %p)>", 2005 " (BoundTargetFunction %p)>",
2002 reinterpret_cast<void*>(bound_function->bound_target_function())); 2006 reinterpret_cast<void*>(bound_function->bound_target_function()));
2003 break; 2007 break;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 } 2223 }
2220 PrintF(file, " "); 2224 PrintF(file, " ");
2221 } 2225 }
2222 } 2226 }
2223 PrintF(file, "\n"); 2227 PrintF(file, "\n");
2224 } 2228 }
2225 2229
2226 2230
2227 void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT 2231 void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
2228 Heap* heap = GetHeap(); 2232 Heap* heap = GetHeap();
2233 Isolate* isolate = heap->isolate();
2229 if (!heap->Contains(this)) { 2234 if (!heap->Contains(this)) {
2230 os << "!!!INVALID POINTER!!!"; 2235 os << "!!!INVALID POINTER!!!";
2231 return; 2236 return;
2232 } 2237 }
2233 if (!heap->Contains(map())) { 2238 if (!heap->Contains(map())) {
2234 os << "!!!INVALID MAP!!!"; 2239 os << "!!!INVALID MAP!!!";
2235 return; 2240 return;
2236 } 2241 }
2237 2242
2238 os << this << " "; 2243 os << this << " ";
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 os << "<" #Name ">"; \ 2309 os << "<" #Name ">"; \
2305 break; 2310 break;
2306 STRUCT_LIST(MAKE_STRUCT_CASE) 2311 STRUCT_LIST(MAKE_STRUCT_CASE)
2307 #undef MAKE_STRUCT_CASE 2312 #undef MAKE_STRUCT_CASE
2308 case CODE_TYPE: { 2313 case CODE_TYPE: {
2309 Code* code = Code::cast(this); 2314 Code* code = Code::cast(this);
2310 os << "<Code: " << Code::Kind2String(code->kind()) << ">"; 2315 os << "<Code: " << Code::Kind2String(code->kind()) << ">";
2311 break; 2316 break;
2312 } 2317 }
2313 case ODDBALL_TYPE: { 2318 case ODDBALL_TYPE: {
2314 if (IsUndefined()) { 2319 if (IsUndefined(isolate)) {
2315 os << "<undefined>"; 2320 os << "<undefined>";
2316 } else if (IsTheHole()) { 2321 } else if (IsTheHole(isolate)) {
2317 os << "<the hole>"; 2322 os << "<the hole>";
2318 } else if (IsNull()) { 2323 } else if (IsNull()) {
2319 os << "<null>"; 2324 os << "<null>";
2320 } else if (IsTrue()) { 2325 } else if (IsTrue()) {
2321 os << "<true>"; 2326 os << "<true>";
2322 } else if (IsFalse()) { 2327 } else if (IsFalse()) {
2323 os << "<false>"; 2328 os << "<false>";
2324 } else { 2329 } else {
2325 os << "<Odd Oddball: "; 2330 os << "<Odd Oddball: ";
2326 os << Oddball::cast(this)->to_string()->ToCString().get(); 2331 os << Oddball::cast(this)->to_string()->ToCString().get();
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 // Need to adjust the details. 2720 // Need to adjust the details.
2716 int index = dict->NextEnumerationIndex(); 2721 int index = dict->NextEnumerationIndex();
2717 dict->SetNextEnumerationIndex(index + 1); 2722 dict->SetNextEnumerationIndex(index + 1);
2718 PropertyCell* cell = PropertyCell::cast(dict->ValueAt(entry)); 2723 PropertyCell* cell = PropertyCell::cast(dict->ValueAt(entry));
2719 details = cell->property_details().set_index(index); 2724 details = cell->property_details().set_index(index);
2720 cell->set_property_details(details); 2725 cell->set_property_details(details);
2721 2726
2722 } else { 2727 } else {
2723 auto cell = isolate->factory()->NewPropertyCell(); 2728 auto cell = isolate->factory()->NewPropertyCell();
2724 cell->set_value(*value); 2729 cell->set_value(*value);
2725 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined 2730 auto cell_type = value->IsUndefined(isolate)
2726 : PropertyCellType::kConstant; 2731 ? PropertyCellType::kUndefined
2732 : PropertyCellType::kConstant;
2727 details = details.set_cell_type(cell_type); 2733 details = details.set_cell_type(cell_type);
2728 value = cell; 2734 value = cell;
2729 2735
2730 Handle<GlobalDictionary> result = 2736 Handle<GlobalDictionary> result =
2731 GlobalDictionary::Add(dict, name, value, details); 2737 GlobalDictionary::Add(dict, name, value, details);
2732 if (*dict != *result) object->set_properties(*result); 2738 if (*dict != *result) object->set_properties(*result);
2733 } 2739 }
2734 } else { 2740 } else {
2735 Handle<NameDictionary> dict(object->property_dictionary()); 2741 Handle<NameDictionary> dict(object->property_dictionary());
2736 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 2742 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 DCHECK(!old_map->is_stable()); 3191 DCHECK(!old_map->is_stable());
3186 DCHECK(new_map->is_stable()); 3192 DCHECK(new_map->is_stable());
3187 // Clear out the old descriptor array to avoid problems to sharing 3193 // Clear out the old descriptor array to avoid problems to sharing
3188 // the descriptor array without using an explicit. 3194 // the descriptor array without using an explicit.
3189 old_map->InitializeDescriptors( 3195 old_map->InitializeDescriptors(
3190 old_map->GetHeap()->empty_descriptor_array(), 3196 old_map->GetHeap()->empty_descriptor_array(),
3191 LayoutDescriptor::FastPointerLayout()); 3197 LayoutDescriptor::FastPointerLayout());
3192 // Ensure that no transition was inserted for prototype migrations. 3198 // Ensure that no transition was inserted for prototype migrations.
3193 DCHECK_EQ( 3199 DCHECK_EQ(
3194 0, TransitionArray::NumberOfTransitions(old_map->raw_transitions())); 3200 0, TransitionArray::NumberOfTransitions(old_map->raw_transitions()));
3195 DCHECK(new_map->GetBackPointer()->IsUndefined()); 3201 DCHECK(new_map->GetBackPointer()->IsUndefined(new_map->GetIsolate()));
3196 } 3202 }
3197 } else { 3203 } else {
3198 MigrateFastToSlow(object, new_map, expected_additional_properties); 3204 MigrateFastToSlow(object, new_map, expected_additional_properties);
3199 } 3205 }
3200 3206
3201 // Careful: Don't allocate here! 3207 // Careful: Don't allocate here!
3202 // For some callers of this method, |object| might be in an inconsistent 3208 // For some callers of this method, |object| might be in an inconsistent
3203 // state now: the new map might have a new elements_kind, but the object's 3209 // state now: the new map might have a new elements_kind, but the object's
3204 // elements pointer hasn't been updated yet. Callers will fix this, but in 3210 // elements pointer hasn't been updated yet. Callers will fix this, but in
3205 // the meantime, (indirectly) calling JSObjectVerify() must be avoided. 3211 // the meantime, (indirectly) calling JSObjectVerify() must be avoided.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds. 3302 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds.
3297 // TODO(ishell): compare AccessorPairs. 3303 // TODO(ishell): compare AccessorPairs.
3298 return false; 3304 return false;
3299 } 3305 }
3300 3306
3301 3307
3302 // Installs |new_descriptors| over the current instance_descriptors to ensure 3308 // Installs |new_descriptors| over the current instance_descriptors to ensure
3303 // proper sharing of descriptor arrays. 3309 // proper sharing of descriptor arrays.
3304 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors, 3310 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors,
3305 LayoutDescriptor* new_layout_descriptor) { 3311 LayoutDescriptor* new_layout_descriptor) {
3312 Isolate* isolate = GetIsolate();
3306 // Don't overwrite the empty descriptor array or initial map's descriptors. 3313 // Don't overwrite the empty descriptor array or initial map's descriptors.
3307 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined()) { 3314 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined(isolate)) {
3308 return; 3315 return;
3309 } 3316 }
3310 3317
3311 DescriptorArray* to_replace = instance_descriptors(); 3318 DescriptorArray* to_replace = instance_descriptors();
3312 GetHeap()->incremental_marking()->IterateBlackObject(to_replace); 3319 isolate->heap()->incremental_marking()->IterateBlackObject(to_replace);
3313 Map* current = this; 3320 Map* current = this;
3314 while (current->instance_descriptors() == to_replace) { 3321 while (current->instance_descriptors() == to_replace) {
3315 Object* next = current->GetBackPointer(); 3322 Object* next = current->GetBackPointer();
3316 if (next->IsUndefined()) break; // Stop overwriting at initial map. 3323 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
3317 current->SetEnumLength(kInvalidEnumCacheSentinel); 3324 current->SetEnumLength(kInvalidEnumCacheSentinel);
3318 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); 3325 current->UpdateDescriptors(new_descriptors, new_layout_descriptor);
3319 current = Map::cast(next); 3326 current = Map::cast(next);
3320 } 3327 }
3321 set_owns_descriptors(false); 3328 set_owns_descriptors(false);
3322 } 3329 }
3323 3330
3324 3331
3325 Map* Map::FindRootMap() { 3332 Map* Map::FindRootMap() {
3326 Map* result = this; 3333 Map* result = this;
3334 Isolate* isolate = GetIsolate();
3327 while (true) { 3335 while (true) {
3328 Object* back = result->GetBackPointer(); 3336 Object* back = result->GetBackPointer();
3329 if (back->IsUndefined()) { 3337 if (back->IsUndefined(isolate)) {
3330 // Initial map always owns descriptors and doesn't have unused entries 3338 // Initial map always owns descriptors and doesn't have unused entries
3331 // in the descriptor array. 3339 // in the descriptor array.
3332 DCHECK(result->owns_descriptors()); 3340 DCHECK(result->owns_descriptors());
3333 DCHECK_EQ(result->NumberOfOwnDescriptors(), 3341 DCHECK_EQ(result->NumberOfOwnDescriptors(),
3334 result->instance_descriptors()->number_of_descriptors()); 3342 result->instance_descriptors()->number_of_descriptors());
3335 return result; 3343 return result;
3336 } 3344 }
3337 result = Map::cast(back); 3345 result = Map::cast(back);
3338 } 3346 }
3339 } 3347 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3377 current = next; 3385 current = next;
3378 } 3386 }
3379 return current; 3387 return current;
3380 } 3388 }
3381 3389
3382 3390
3383 Map* Map::FindFieldOwner(int descriptor) { 3391 Map* Map::FindFieldOwner(int descriptor) {
3384 DisallowHeapAllocation no_allocation; 3392 DisallowHeapAllocation no_allocation;
3385 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type()); 3393 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type());
3386 Map* result = this; 3394 Map* result = this;
3395 Isolate* isolate = GetIsolate();
3387 while (true) { 3396 while (true) {
3388 Object* back = result->GetBackPointer(); 3397 Object* back = result->GetBackPointer();
3389 if (back->IsUndefined()) break; 3398 if (back->IsUndefined(isolate)) break;
3390 Map* parent = Map::cast(back); 3399 Map* parent = Map::cast(back);
3391 if (parent->NumberOfOwnDescriptors() <= descriptor) break; 3400 if (parent->NumberOfOwnDescriptors() <= descriptor) break;
3392 result = parent; 3401 result = parent;
3393 } 3402 }
3394 return result; 3403 return result;
3395 } 3404 }
3396 3405
3397 3406
3398 void Map::UpdateFieldType(int descriptor, Handle<Name> name, 3407 void Map::UpdateFieldType(int descriptor, Handle<Name> name,
3399 Representation new_representation, 3408 Representation new_representation,
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it, 4192 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it,
4184 ShouldThrow should_throw, 4193 ShouldThrow should_throw,
4185 Handle<Object> value) { 4194 Handle<Object> value) {
4186 Isolate* isolate = it->isolate(); 4195 Isolate* isolate = it->isolate();
4187 // Make sure that the top context does not change when doing callbacks or 4196 // Make sure that the top context does not change when doing callbacks or
4188 // interceptor calls. 4197 // interceptor calls.
4189 AssertNoContextChange ncc(isolate); 4198 AssertNoContextChange ncc(isolate);
4190 4199
4191 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 4200 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
4192 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); 4201 Handle<InterceptorInfo> interceptor(it->GetInterceptor());
4193 if (interceptor->setter()->IsUndefined()) return Just(false); 4202 if (interceptor->setter()->IsUndefined(isolate)) return Just(false);
4194 4203
4195 Handle<JSObject> holder = it->GetHolder<JSObject>(); 4204 Handle<JSObject> holder = it->GetHolder<JSObject>();
4196 bool result; 4205 bool result;
4197 Handle<Object> receiver = it->GetReceiver(); 4206 Handle<Object> receiver = it->GetReceiver();
4198 if (!receiver->IsJSReceiver()) { 4207 if (!receiver->IsJSReceiver()) {
4199 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 4208 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
4200 Object::ConvertReceiver(isolate, receiver), 4209 Object::ConvertReceiver(isolate, receiver),
4201 Nothing<bool>()); 4210 Nothing<bool>());
4202 } 4211 }
4203 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 4212 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 4503 // Proxies are handled elsewhere. Other non-JSObjects cannot have own
4495 // properties. 4504 // properties.
4496 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); 4505 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver());
4497 4506
4498 // Store on the holder which may be hidden behind the receiver. 4507 // Store on the holder which may be hidden behind the receiver.
4499 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); 4508 DCHECK(it->HolderIsReceiverOrHiddenPrototype());
4500 4509
4501 Handle<Object> to_assign = value; 4510 Handle<Object> to_assign = value;
4502 // Convert the incoming value to a number for storing into typed arrays. 4511 // Convert the incoming value to a number for storing into typed arrays.
4503 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) { 4512 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) {
4504 if (!value->IsNumber() && !value->IsUndefined()) { 4513 if (!value->IsNumber() && !value->IsUndefined(it->isolate())) {
4505 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4514 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4506 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>()); 4515 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>());
4507 // We have to recheck the length. However, it can only change if the 4516 // We have to recheck the length. However, it can only change if the
4508 // underlying buffer was neutered, so just check that. 4517 // underlying buffer was neutered, so just check that.
4509 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { 4518 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) {
4510 return Just(true); 4519 return Just(true);
4511 // TODO(neis): According to the spec, this should throw a TypeError. 4520 // TODO(neis): According to the spec, this should throw a TypeError.
4512 } 4521 }
4513 } 4522 }
4514 } 4523 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 4642
4634 // If the source descriptors had an enum cache we copy it. This ensures 4643 // 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 4644 // 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 4645 // 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 4646 // enumerated descriptors than available in the original cache, the cache
4638 // will be lazily replaced by the extended cache when needed. 4647 // will be lazily replaced by the extended cache when needed.
4639 if (descriptors->HasEnumCache()) { 4648 if (descriptors->HasEnumCache()) {
4640 new_descriptors->CopyEnumCacheFrom(*descriptors); 4649 new_descriptors->CopyEnumCacheFrom(*descriptors);
4641 } 4650 }
4642 4651
4652 Isolate* isolate = map->GetIsolate();
4643 // Replace descriptors by new_descriptors in all maps that share it. 4653 // Replace descriptors by new_descriptors in all maps that share it.
4644 map->GetHeap()->incremental_marking()->IterateBlackObject(*descriptors); 4654 isolate->heap()->incremental_marking()->IterateBlackObject(*descriptors);
4645 4655
4646 Map* current = *map; 4656 Map* current = *map;
4647 while (current->instance_descriptors() == *descriptors) { 4657 while (current->instance_descriptors() == *descriptors) {
4648 Object* next = current->GetBackPointer(); 4658 Object* next = current->GetBackPointer();
4649 if (next->IsUndefined()) break; // Stop overwriting at initial map. 4659 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
4650 current->UpdateDescriptors(*new_descriptors, layout_descriptor); 4660 current->UpdateDescriptors(*new_descriptors, layout_descriptor);
4651 current = Map::cast(next); 4661 current = Map::cast(next);
4652 } 4662 }
4653 map->UpdateDescriptors(*new_descriptors, layout_descriptor); 4663 map->UpdateDescriptors(*new_descriptors, layout_descriptor);
4654 } 4664 }
4655 4665
4656 4666
4657 template<class T> 4667 template<class T>
4658 static int AppendUniqueCallbacks(NeanderArray* callbacks, 4668 static int AppendUniqueCallbacks(NeanderArray* callbacks,
4659 Handle<typename T::Array> array, 4669 Handle<typename T::Array> array,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
4883 DisallowHeapAllocation no_gc; 4893 DisallowHeapAllocation no_gc;
4884 if (native_context->get(Context::ArrayMapIndex(from_kind)) == *map) { 4894 if (native_context->get(Context::ArrayMapIndex(from_kind)) == *map) {
4885 Object* maybe_transitioned_map = 4895 Object* maybe_transitioned_map =
4886 native_context->get(Context::ArrayMapIndex(to_kind)); 4896 native_context->get(Context::ArrayMapIndex(to_kind));
4887 if (maybe_transitioned_map->IsMap()) { 4897 if (maybe_transitioned_map->IsMap()) {
4888 return handle(Map::cast(maybe_transitioned_map), isolate); 4898 return handle(Map::cast(maybe_transitioned_map), isolate);
4889 } 4899 }
4890 } 4900 }
4891 } 4901 }
4892 4902
4893 DCHECK(!map->IsUndefined()); 4903 DCHECK(!map->IsUndefined(isolate));
4894 // Check if we can go back in the elements kind transition chain. 4904 // Check if we can go back in the elements kind transition chain.
4895 if (IsHoleyElementsKind(from_kind) && 4905 if (IsHoleyElementsKind(from_kind) &&
4896 to_kind == GetPackedElementsKind(from_kind) && 4906 to_kind == GetPackedElementsKind(from_kind) &&
4897 map->GetBackPointer()->IsMap() && 4907 map->GetBackPointer()->IsMap() &&
4898 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { 4908 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) {
4899 return handle(Map::cast(map->GetBackPointer())); 4909 return handle(Map::cast(map->GetBackPointer()));
4900 } 4910 }
4901 4911
4902 bool allow_store_transition = IsTransitionElementsKind(from_kind); 4912 bool allow_store_transition = IsTransitionElementsKind(from_kind);
4903 // Only store fast element maps in ascending generality. 4913 // Only store fast element maps in ascending generality.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4957 } 4967 }
4958 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 4968 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
4959 Handle<JSReceiver> target(proxy->target(), isolate); 4969 Handle<JSReceiver> target(proxy->target(), isolate);
4960 // 6. Let trap be ? GetMethod(handler, "has"). 4970 // 6. Let trap be ? GetMethod(handler, "has").
4961 Handle<Object> trap; 4971 Handle<Object> trap;
4962 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4972 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4963 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), 4973 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler),
4964 isolate->factory()->has_string()), 4974 isolate->factory()->has_string()),
4965 Nothing<bool>()); 4975 Nothing<bool>());
4966 // 7. If trap is undefined, then 4976 // 7. If trap is undefined, then
4967 if (trap->IsUndefined()) { 4977 if (trap->IsUndefined(isolate)) {
4968 // 7a. Return target.[[HasProperty]](P). 4978 // 7a. Return target.[[HasProperty]](P).
4969 return JSReceiver::HasProperty(target, name); 4979 return JSReceiver::HasProperty(target, name);
4970 } 4980 }
4971 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)). 4981 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)).
4972 Handle<Object> trap_result_obj; 4982 Handle<Object> trap_result_obj;
4973 Handle<Object> args[] = {target, name}; 4983 Handle<Object> args[] = {target, name};
4974 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 4984 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
4975 isolate, trap_result_obj, 4985 isolate, trap_result_obj,
4976 Execution::Call(isolate, trap, handler, arraysize(args), args), 4986 Execution::Call(isolate, trap, handler, arraysize(args), args),
4977 Nothing<bool>()); 4987 Nothing<bool>());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 isolate->Throw( 5033 isolate->Throw(
5024 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 5034 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
5025 return Nothing<bool>(); 5035 return Nothing<bool>();
5026 } 5036 }
5027 Handle<JSReceiver> target(proxy->target(), isolate); 5037 Handle<JSReceiver> target(proxy->target(), isolate);
5028 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 5038 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
5029 5039
5030 Handle<Object> trap; 5040 Handle<Object> trap;
5031 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5041 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5032 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 5042 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
5033 if (trap->IsUndefined()) { 5043 if (trap->IsUndefined(isolate)) {
5034 LookupIterator it = 5044 LookupIterator it =
5035 LookupIterator::PropertyOrElement(isolate, receiver, name, target); 5045 LookupIterator::PropertyOrElement(isolate, receiver, name, target);
5036 return Object::SetSuperProperty(&it, value, language_mode, 5046 return Object::SetSuperProperty(&it, value, language_mode,
5037 Object::MAY_BE_STORE_FROM_KEYED); 5047 Object::MAY_BE_STORE_FROM_KEYED);
5038 } 5048 }
5039 5049
5040 Handle<Object> trap_result; 5050 Handle<Object> trap_result;
5041 Handle<Object> args[] = {target, name, value, receiver}; 5051 Handle<Object> args[] = {target, name, value, receiver};
5042 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5052 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5043 isolate, trap_result, 5053 isolate, trap_result,
(...skipping 15 matching lines...) Expand all
5059 !target_desc.configurable() && 5069 !target_desc.configurable() &&
5060 !target_desc.writable() && 5070 !target_desc.writable() &&
5061 !value->SameValue(*target_desc.value()); 5071 !value->SameValue(*target_desc.value());
5062 if (inconsistent) { 5072 if (inconsistent) {
5063 isolate->Throw(*isolate->factory()->NewTypeError( 5073 isolate->Throw(*isolate->factory()->NewTypeError(
5064 MessageTemplate::kProxySetFrozenData, name)); 5074 MessageTemplate::kProxySetFrozenData, name));
5065 return Nothing<bool>(); 5075 return Nothing<bool>();
5066 } 5076 }
5067 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && 5077 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
5068 !target_desc.configurable() && 5078 !target_desc.configurable() &&
5069 target_desc.set()->IsUndefined(); 5079 target_desc.set()->IsUndefined(isolate);
5070 if (inconsistent) { 5080 if (inconsistent) {
5071 isolate->Throw(*isolate->factory()->NewTypeError( 5081 isolate->Throw(*isolate->factory()->NewTypeError(
5072 MessageTemplate::kProxySetFrozenAccessor, name)); 5082 MessageTemplate::kProxySetFrozenAccessor, name));
5073 return Nothing<bool>(); 5083 return Nothing<bool>();
5074 } 5084 }
5075 } 5085 }
5076 return Just(true); 5086 return Just(true);
5077 } 5087 }
5078 5088
5079 5089
(...skipping 12 matching lines...) Expand all
5092 isolate->Throw( 5102 isolate->Throw(
5093 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 5103 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
5094 return Nothing<bool>(); 5104 return Nothing<bool>();
5095 } 5105 }
5096 Handle<JSReceiver> target(proxy->target(), isolate); 5106 Handle<JSReceiver> target(proxy->target(), isolate);
5097 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 5107 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
5098 5108
5099 Handle<Object> trap; 5109 Handle<Object> trap;
5100 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5110 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5101 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 5111 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
5102 if (trap->IsUndefined()) { 5112 if (trap->IsUndefined(isolate)) {
5103 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); 5113 return JSReceiver::DeletePropertyOrElement(target, name, language_mode);
5104 } 5114 }
5105 5115
5106 Handle<Object> trap_result; 5116 Handle<Object> trap_result;
5107 Handle<Object> args[] = {target, name}; 5117 Handle<Object> args[] = {target, name};
5108 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 5118 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
5109 isolate, trap_result, 5119 isolate, trap_result,
5110 Execution::Call(isolate, trap, handler, arraysize(args), args), 5120 Execution::Call(isolate, trap, handler, arraysize(args), args),
5111 Nothing<bool>()); 5121 Nothing<bool>());
5112 if (!trap_result->BooleanValue()) { 5122 if (!trap_result->BooleanValue()) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
5441 } 5451 }
5442 } 5452 }
5443 5453
5444 return AddDataProperty(it, value, attributes, should_throw, 5454 return AddDataProperty(it, value, attributes, should_throw,
5445 CERTAINLY_NOT_STORE_FROM_KEYED); 5455 CERTAINLY_NOT_STORE_FROM_KEYED);
5446 } 5456 }
5447 5457
5448 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( 5458 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
5449 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, 5459 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
5450 PropertyAttributes attributes) { 5460 PropertyAttributes attributes) {
5451 DCHECK(!value->IsTheHole()); 5461 DCHECK(!value->IsTheHole(object->GetIsolate()));
5452 LookupIterator it(object, name, object, LookupIterator::OWN); 5462 LookupIterator it(object, name, object, LookupIterator::OWN);
5453 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); 5463 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
5454 } 5464 }
5455 5465
5456 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( 5466 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
5457 Handle<JSObject> object, uint32_t index, Handle<Object> value, 5467 Handle<JSObject> object, uint32_t index, Handle<Object> value,
5458 PropertyAttributes attributes) { 5468 PropertyAttributes attributes) {
5459 Isolate* isolate = object->GetIsolate(); 5469 Isolate* isolate = object->GetIsolate();
5460 LookupIterator it(isolate, object, index, object, LookupIterator::OWN); 5470 LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
5461 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); 5471 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
(...skipping 24 matching lines...) Expand all
5486 return Just(ABSENT); 5496 return Just(ABSENT);
5487 } 5497 }
5488 Handle<Object> receiver = it->GetReceiver(); 5498 Handle<Object> receiver = it->GetReceiver();
5489 if (!receiver->IsJSReceiver()) { 5499 if (!receiver->IsJSReceiver()) {
5490 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 5500 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
5491 Object::ConvertReceiver(isolate, receiver), 5501 Object::ConvertReceiver(isolate, receiver),
5492 Nothing<PropertyAttributes>()); 5502 Nothing<PropertyAttributes>());
5493 } 5503 }
5494 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 5504 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
5495 *holder, Object::DONT_THROW); 5505 *holder, Object::DONT_THROW);
5496 if (!interceptor->query()->IsUndefined()) { 5506 if (!interceptor->query()->IsUndefined(isolate)) {
5497 Handle<Object> result; 5507 Handle<Object> result;
5498 if (it->IsElement()) { 5508 if (it->IsElement()) {
5499 uint32_t index = it->index(); 5509 uint32_t index = it->index();
5500 v8::IndexedPropertyQueryCallback query = 5510 v8::IndexedPropertyQueryCallback query =
5501 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); 5511 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query());
5502 result = args.Call(query, index); 5512 result = args.Call(query, index);
5503 } else { 5513 } else {
5504 Handle<Name> name = it->name(); 5514 Handle<Name> name = it->name();
5505 DCHECK(!name->IsPrivate()); 5515 DCHECK(!name->IsPrivate());
5506 v8::GenericNamedPropertyQueryCallback query = 5516 v8::GenericNamedPropertyQueryCallback query =
5507 v8::ToCData<v8::GenericNamedPropertyQueryCallback>( 5517 v8::ToCData<v8::GenericNamedPropertyQueryCallback>(
5508 interceptor->query()); 5518 interceptor->query());
5509 result = args.Call(query, name); 5519 result = args.Call(query, name);
5510 } 5520 }
5511 if (!result.is_null()) { 5521 if (!result.is_null()) {
5512 int32_t value; 5522 int32_t value;
5513 CHECK(result->ToInt32(&value)); 5523 CHECK(result->ToInt32(&value));
5514 return Just(static_cast<PropertyAttributes>(value)); 5524 return Just(static_cast<PropertyAttributes>(value));
5515 } 5525 }
5516 } else if (!interceptor->getter()->IsUndefined()) { 5526 } else if (!interceptor->getter()->IsUndefined(isolate)) {
5517 // TODO(verwaest): Use GetPropertyWithInterceptor? 5527 // TODO(verwaest): Use GetPropertyWithInterceptor?
5518 Handle<Object> result; 5528 Handle<Object> result;
5519 if (it->IsElement()) { 5529 if (it->IsElement()) {
5520 uint32_t index = it->index(); 5530 uint32_t index = it->index();
5521 v8::IndexedPropertyGetterCallback getter = 5531 v8::IndexedPropertyGetterCallback getter =
5522 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); 5532 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
5523 result = args.Call(getter, index); 5533 result = args.Call(getter, index);
5524 } else { 5534 } else {
5525 Handle<Name> name = it->name(); 5535 Handle<Name> name = it->name();
5526 DCHECK(!name->IsPrivate()); 5536 DCHECK(!name->IsPrivate());
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
5926 5936
5927 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it, 5937 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it,
5928 ShouldThrow should_throw) { 5938 ShouldThrow should_throw) {
5929 Isolate* isolate = it->isolate(); 5939 Isolate* isolate = it->isolate();
5930 // Make sure that the top context does not change when doing callbacks or 5940 // Make sure that the top context does not change when doing callbacks or
5931 // interceptor calls. 5941 // interceptor calls.
5932 AssertNoContextChange ncc(isolate); 5942 AssertNoContextChange ncc(isolate);
5933 5943
5934 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 5944 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
5935 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); 5945 Handle<InterceptorInfo> interceptor(it->GetInterceptor());
5936 if (interceptor->deleter()->IsUndefined()) return Nothing<bool>(); 5946 if (interceptor->deleter()->IsUndefined(isolate)) return Nothing<bool>();
5937 5947
5938 Handle<JSObject> holder = it->GetHolder<JSObject>(); 5948 Handle<JSObject> holder = it->GetHolder<JSObject>();
5939 Handle<Object> receiver = it->GetReceiver(); 5949 Handle<Object> receiver = it->GetReceiver();
5940 if (!receiver->IsJSReceiver()) { 5950 if (!receiver->IsJSReceiver()) {
5941 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, 5951 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
5942 Object::ConvertReceiver(isolate, receiver), 5952 Object::ConvertReceiver(isolate, receiver),
5943 Nothing<bool>()); 5953 Nothing<bool>());
5944 } 5954 }
5945 5955
5946 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, 5956 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6863 } 6873 }
6864 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 6874 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
6865 Handle<JSReceiver> target(proxy->target(), isolate); 6875 Handle<JSReceiver> target(proxy->target(), isolate);
6866 // 6. Let trap be ? GetMethod(handler, "defineProperty"). 6876 // 6. Let trap be ? GetMethod(handler, "defineProperty").
6867 Handle<Object> trap; 6877 Handle<Object> trap;
6868 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 6878 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6869 isolate, trap, 6879 isolate, trap,
6870 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 6880 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
6871 Nothing<bool>()); 6881 Nothing<bool>());
6872 // 7. If trap is undefined, then: 6882 // 7. If trap is undefined, then:
6873 if (trap->IsUndefined()) { 6883 if (trap->IsUndefined(isolate)) {
6874 // 7a. Return target.[[DefineOwnProperty]](P, Desc). 6884 // 7a. Return target.[[DefineOwnProperty]](P, Desc).
6875 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, 6885 return JSReceiver::DefineOwnProperty(isolate, target, key, desc,
6876 should_throw); 6886 should_throw);
6877 } 6887 }
6878 // 8. Let descObj be FromPropertyDescriptor(Desc). 6888 // 8. Let descObj be FromPropertyDescriptor(Desc).
6879 Handle<Object> desc_obj = desc->ToObject(isolate); 6889 Handle<Object> desc_obj = desc->ToObject(isolate);
6880 // 9. Let booleanTrapResult be 6890 // 9. Let booleanTrapResult be
6881 // ToBoolean(? Call(trap, handler, «target, P, descObj»)). 6891 // ToBoolean(? Call(trap, handler, «target, P, descObj»)).
6882 Handle<Name> property_name = 6892 Handle<Name> property_name =
6883 key->IsName() 6893 key->IsName()
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
7081 } 7091 }
7082 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 7092 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
7083 Handle<JSReceiver> target(proxy->target(), isolate); 7093 Handle<JSReceiver> target(proxy->target(), isolate);
7084 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). 7094 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor").
7085 Handle<Object> trap; 7095 Handle<Object> trap;
7086 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7096 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7087 isolate, trap, 7097 isolate, trap,
7088 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 7098 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
7089 Nothing<bool>()); 7099 Nothing<bool>());
7090 // 7. If trap is undefined, then 7100 // 7. If trap is undefined, then
7091 if (trap->IsUndefined()) { 7101 if (trap->IsUndefined(isolate)) {
7092 // 7a. Return target.[[GetOwnProperty]](P). 7102 // 7a. Return target.[[GetOwnProperty]](P).
7093 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); 7103 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc);
7094 } 7104 }
7095 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»). 7105 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»).
7096 Handle<Object> trap_result_obj; 7106 Handle<Object> trap_result_obj;
7097 Handle<Object> args[] = {target, name}; 7107 Handle<Object> args[] = {target, name};
7098 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7108 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7099 isolate, trap_result_obj, 7109 isolate, trap_result_obj,
7100 Execution::Call(isolate, trap, handler, arraysize(args), args), 7110 Execution::Call(isolate, trap, handler, arraysize(args), args),
7101 Nothing<bool>()); 7111 Nothing<bool>());
7102 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a 7112 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a
7103 // TypeError exception. 7113 // TypeError exception.
7104 if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) { 7114 if (!trap_result_obj->IsJSReceiver() &&
7115 !trap_result_obj->IsUndefined(isolate)) {
7105 isolate->Throw(*isolate->factory()->NewTypeError( 7116 isolate->Throw(*isolate->factory()->NewTypeError(
7106 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name)); 7117 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name));
7107 return Nothing<bool>(); 7118 return Nothing<bool>();
7108 } 7119 }
7109 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). 7120 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P).
7110 PropertyDescriptor target_desc; 7121 PropertyDescriptor target_desc;
7111 Maybe<bool> found = 7122 Maybe<bool> found =
7112 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); 7123 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
7113 MAYBE_RETURN(found, Nothing<bool>()); 7124 MAYBE_RETURN(found, Nothing<bool>());
7114 // 11. If trapResultObj is undefined, then 7125 // 11. If trapResultObj is undefined, then
7115 if (trap_result_obj->IsUndefined()) { 7126 if (trap_result_obj->IsUndefined(isolate)) {
7116 // 11a. If targetDesc is undefined, return undefined. 7127 // 11a. If targetDesc is undefined, return undefined.
7117 if (!found.FromJust()) return Just(false); 7128 if (!found.FromJust()) return Just(false);
7118 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError 7129 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError
7119 // exception. 7130 // exception.
7120 if (!target_desc.configurable()) { 7131 if (!target_desc.configurable()) {
7121 isolate->Throw(*isolate->factory()->NewTypeError( 7132 isolate->Throw(*isolate->factory()->NewTypeError(
7122 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name)); 7133 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name));
7123 return Nothing<bool>(); 7134 return Nothing<bool>();
7124 } 7135 }
7125 // 11c. Let extensibleTarget be ? IsExtensible(target). 7136 // 11c. Let extensibleTarget be ? IsExtensible(target).
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
7170 } 7181 }
7171 } 7182 }
7172 // 18. Return resultDesc. 7183 // 18. Return resultDesc.
7173 return Just(true); 7184 return Just(true);
7174 } 7185 }
7175 7186
7176 7187
7177 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, 7188 bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
7178 ElementsKind kind, 7189 ElementsKind kind,
7179 Object* object) { 7190 Object* object) {
7191 Isolate* isolate = elements->GetIsolate();
7180 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) { 7192 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) {
7181 int length = IsJSArray() 7193 int length = IsJSArray()
7182 ? Smi::cast(JSArray::cast(this)->length())->value() 7194 ? Smi::cast(JSArray::cast(this)->length())->value()
7183 : elements->length(); 7195 : elements->length();
7184 for (int i = 0; i < length; ++i) { 7196 for (int i = 0; i < length; ++i) {
7185 Object* element = elements->get(i); 7197 Object* element = elements->get(i);
7186 if (!element->IsTheHole() && element == object) return true; 7198 if (!element->IsTheHole(isolate) && element == object) return true;
7187 } 7199 }
7188 } else { 7200 } else {
7189 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS); 7201 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS);
7190 Object* key = 7202 Object* key =
7191 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object); 7203 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object);
7192 if (!key->IsUndefined()) return true; 7204 if (!key->IsUndefined(isolate)) return true;
7193 } 7205 }
7194 return false; 7206 return false;
7195 } 7207 }
7196 7208
7197 7209
7198 // Check whether this object references another object. 7210 // Check whether this object references another object.
7199 bool JSObject::ReferencesObject(Object* obj) { 7211 bool JSObject::ReferencesObject(Object* obj) {
7200 Map* map_of_this = map(); 7212 Map* map_of_this = map();
7201 Heap* heap = GetHeap(); 7213 Heap* heap = GetHeap();
7202 DisallowHeapAllocation no_allocation; 7214 DisallowHeapAllocation no_allocation;
7203 7215
7204 // Is the object the constructor for this object? 7216 // Is the object the constructor for this object?
7205 if (map_of_this->GetConstructor() == obj) { 7217 if (map_of_this->GetConstructor() == obj) {
7206 return true; 7218 return true;
7207 } 7219 }
7208 7220
7209 // Is the object the prototype for this object? 7221 // Is the object the prototype for this object?
7210 if (map_of_this->prototype() == obj) { 7222 if (map_of_this->prototype() == obj) {
7211 return true; 7223 return true;
7212 } 7224 }
7213 7225
7214 // Check if the object is among the named properties. 7226 // Check if the object is among the named properties.
7215 Object* key = SlowReverseLookup(obj); 7227 Object* key = SlowReverseLookup(obj);
7216 if (!key->IsUndefined()) { 7228 if (!key->IsUndefined(heap->isolate())) {
7217 return true; 7229 return true;
7218 } 7230 }
7219 7231
7220 // Check if the object is among the indexed properties. 7232 // Check if the object is among the indexed properties.
7221 ElementsKind kind = GetElementsKind(); 7233 ElementsKind kind = GetElementsKind();
7222 switch (kind) { 7234 switch (kind) {
7223 // Raw pixels and external arrays do not reference other 7235 // Raw pixels and external arrays do not reference other
7224 // objects. 7236 // objects.
7225 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 7237 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
7226 case TYPE##_ELEMENTS: \ 7238 case TYPE##_ELEMENTS: \
(...skipping 17 matching lines...) Expand all
7244 if (ReferencesObjectFromElements(elements, kind, obj)) return true; 7256 if (ReferencesObjectFromElements(elements, kind, obj)) return true;
7245 break; 7257 break;
7246 } 7258 }
7247 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 7259 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
7248 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { 7260 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: {
7249 FixedArray* parameter_map = FixedArray::cast(elements()); 7261 FixedArray* parameter_map = FixedArray::cast(elements());
7250 // Check the mapped parameters. 7262 // Check the mapped parameters.
7251 int length = parameter_map->length(); 7263 int length = parameter_map->length();
7252 for (int i = 2; i < length; ++i) { 7264 for (int i = 2; i < length; ++i) {
7253 Object* value = parameter_map->get(i); 7265 Object* value = parameter_map->get(i);
7254 if (!value->IsTheHole() && value == obj) return true; 7266 if (!value->IsTheHole(heap->isolate()) && value == obj) return true;
7255 } 7267 }
7256 // Check the arguments. 7268 // Check the arguments.
7257 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); 7269 FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
7258 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : 7270 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS :
7259 FAST_HOLEY_ELEMENTS; 7271 FAST_HOLEY_ELEMENTS;
7260 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; 7272 if (ReferencesObjectFromElements(arguments, kind, obj)) return true;
7261 break; 7273 break;
7262 } 7274 }
7263 case NO_ELEMENTS: 7275 case NO_ELEMENTS:
7264 break; 7276 break;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
7431 isolate->Throw( 7443 isolate->Throw(
7432 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7444 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7433 return Nothing<bool>(); 7445 return Nothing<bool>();
7434 } 7446 }
7435 Handle<JSReceiver> target(proxy->target(), isolate); 7447 Handle<JSReceiver> target(proxy->target(), isolate);
7436 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7448 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7437 7449
7438 Handle<Object> trap; 7450 Handle<Object> trap;
7439 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7451 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7440 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 7452 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
7441 if (trap->IsUndefined()) { 7453 if (trap->IsUndefined(isolate)) {
7442 return JSReceiver::PreventExtensions(target, should_throw); 7454 return JSReceiver::PreventExtensions(target, should_throw);
7443 } 7455 }
7444 7456
7445 Handle<Object> trap_result; 7457 Handle<Object> trap_result;
7446 Handle<Object> args[] = {target}; 7458 Handle<Object> args[] = {target};
7447 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7459 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7448 isolate, trap_result, 7460 isolate, trap_result,
7449 Execution::Call(isolate, trap, handler, arraysize(args), args), 7461 Execution::Call(isolate, trap, handler, arraysize(args), args),
7450 Nothing<bool>()); 7462 Nothing<bool>());
7451 if (!trap_result->BooleanValue()) { 7463 if (!trap_result->BooleanValue()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7533 isolate->Throw( 7545 isolate->Throw(
7534 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7546 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7535 return Nothing<bool>(); 7547 return Nothing<bool>();
7536 } 7548 }
7537 Handle<JSReceiver> target(proxy->target(), isolate); 7549 Handle<JSReceiver> target(proxy->target(), isolate);
7538 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7550 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7539 7551
7540 Handle<Object> trap; 7552 Handle<Object> trap;
7541 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7553 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7542 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); 7554 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
7543 if (trap->IsUndefined()) { 7555 if (trap->IsUndefined(isolate)) {
7544 return JSReceiver::IsExtensible(target); 7556 return JSReceiver::IsExtensible(target);
7545 } 7557 }
7546 7558
7547 Handle<Object> trap_result; 7559 Handle<Object> trap_result;
7548 Handle<Object> args[] = {target}; 7560 Handle<Object> args[] = {target};
7549 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7561 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
7550 isolate, trap_result, 7562 isolate, trap_result,
7551 Execution::Call(isolate, trap, handler, arraysize(args), args), 7563 Execution::Call(isolate, trap, handler, arraysize(args), args),
7552 Nothing<bool>()); 7564 Nothing<bool>());
7553 7565
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
7985 } 7997 }
7986 7998
7987 // static 7999 // static
7988 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver, 8000 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver,
7989 ToPrimitiveHint hint) { 8001 ToPrimitiveHint hint) {
7990 Isolate* const isolate = receiver->GetIsolate(); 8002 Isolate* const isolate = receiver->GetIsolate();
7991 Handle<Object> exotic_to_prim; 8003 Handle<Object> exotic_to_prim;
7992 ASSIGN_RETURN_ON_EXCEPTION( 8004 ASSIGN_RETURN_ON_EXCEPTION(
7993 isolate, exotic_to_prim, 8005 isolate, exotic_to_prim,
7994 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object); 8006 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object);
7995 if (!exotic_to_prim->IsUndefined()) { 8007 if (!exotic_to_prim->IsUndefined(isolate)) {
7996 Handle<Object> hint_string; 8008 Handle<Object> hint_string;
7997 switch (hint) { 8009 switch (hint) {
7998 case ToPrimitiveHint::kDefault: 8010 case ToPrimitiveHint::kDefault:
7999 hint_string = isolate->factory()->default_string(); 8011 hint_string = isolate->factory()->default_string();
8000 break; 8012 break;
8001 case ToPrimitiveHint::kNumber: 8013 case ToPrimitiveHint::kNumber:
8002 hint_string = isolate->factory()->number_string(); 8014 hint_string = isolate->factory()->number_string();
8003 break; 8015 break;
8004 case ToPrimitiveHint::kString: 8016 case ToPrimitiveHint::kString:
8005 hint_string = isolate->factory()->string_string(); 8017 hint_string = isolate->factory()->string_string();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
8363 } 8375 }
8364 it->Next(); 8376 it->Next();
8365 } 8377 }
8366 8378
8367 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); 8379 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
8368 // Ignore accessors on typed arrays. 8380 // Ignore accessors on typed arrays.
8369 if (it->IsElement() && object->HasFixedTypedArrayElements()) { 8381 if (it->IsElement() && object->HasFixedTypedArrayElements()) {
8370 return it->factory()->undefined_value(); 8382 return it->factory()->undefined_value();
8371 } 8383 }
8372 8384
8373 DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull() || 8385 DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) ||
8374 getter->IsFunctionTemplateInfo()); 8386 getter->IsNull() || getter->IsFunctionTemplateInfo());
8375 DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() || 8387 DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) ||
8376 getter->IsFunctionTemplateInfo()); 8388 setter->IsNull() || getter->IsFunctionTemplateInfo());
8377 it->TransitionToAccessorProperty(getter, setter, attributes); 8389 it->TransitionToAccessorProperty(getter, setter, attributes);
8378 8390
8379 return isolate->factory()->undefined_value(); 8391 return isolate->factory()->undefined_value();
8380 } 8392 }
8381 8393
8382 8394
8383 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, 8395 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
8384 Handle<AccessorInfo> info) { 8396 Handle<AccessorInfo> info) {
8385 Isolate* isolate = object->GetIsolate(); 8397 Isolate* isolate = object->GetIsolate();
8386 Handle<Name> name(Name::cast(info->name()), isolate); 8398 Handle<Name> name(Name::cast(info->name()), isolate);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
8484 } 8496 }
8485 8497
8486 8498
8487 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, 8499 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode,
8488 const char* reason) { 8500 const char* reason) {
8489 DCHECK(!fast_map->is_dictionary_map()); 8501 DCHECK(!fast_map->is_dictionary_map());
8490 8502
8491 Isolate* isolate = fast_map->GetIsolate(); 8503 Isolate* isolate = fast_map->GetIsolate();
8492 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(), 8504 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
8493 isolate); 8505 isolate);
8494 bool use_cache = !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(); 8506 bool use_cache =
8507 !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(isolate);
8495 Handle<NormalizedMapCache> cache; 8508 Handle<NormalizedMapCache> cache;
8496 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache); 8509 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
8497 8510
8498 Handle<Map> new_map; 8511 Handle<Map> new_map;
8499 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) { 8512 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) {
8500 #ifdef VERIFY_HEAP 8513 #ifdef VERIFY_HEAP
8501 if (FLAG_verify_heap) new_map->DictionaryMapVerify(); 8514 if (FLAG_verify_heap) new_map->DictionaryMapVerify();
8502 #endif 8515 #endif
8503 #ifdef ENABLE_SLOW_DCHECKS 8516 #ifdef ENABLE_SLOW_DCHECKS
8504 if (FLAG_enable_slow_asserts) { 8517 if (FLAG_enable_slow_asserts) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
8695 Map::TraceTransition("Transition", map, target, key); 8708 Map::TraceTransition("Transition", map, target, key);
8696 Map::TraceAllTransitions(target); 8709 Map::TraceAllTransitions(target);
8697 } 8710 }
8698 } 8711 }
8699 8712
8700 #endif // TRACE_MAPS 8713 #endif // TRACE_MAPS
8701 8714
8702 8715
8703 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, 8716 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child,
8704 Handle<Name> name, SimpleTransitionFlag flag) { 8717 Handle<Name> name, SimpleTransitionFlag flag) {
8705 if (!parent->GetBackPointer()->IsUndefined()) { 8718 if (!parent->GetBackPointer()->IsUndefined(parent->GetIsolate())) {
8706 parent->set_owns_descriptors(false); 8719 parent->set_owns_descriptors(false);
8707 } else { 8720 } else {
8708 // |parent| is initial map and it must keep the ownership, there must be no 8721 // |parent| is initial map and it must keep the ownership, there must be no
8709 // descriptors in the descriptors array that do not belong to the map. 8722 // descriptors in the descriptors array that do not belong to the map.
8710 DCHECK(parent->owns_descriptors()); 8723 DCHECK(parent->owns_descriptors());
8711 DCHECK_EQ(parent->NumberOfOwnDescriptors(), 8724 DCHECK_EQ(parent->NumberOfOwnDescriptors(),
8712 parent->instance_descriptors()->number_of_descriptors()); 8725 parent->instance_descriptors()->number_of_descriptors());
8713 } 8726 }
8714 if (parent->is_prototype_map()) { 8727 if (parent->is_prototype_map()) {
8715 DCHECK(child->is_prototype_map()); 8728 DCHECK(child->is_prototype_map());
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
9278 } 9291 }
9279 9292
9280 9293
9281 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map, 9294 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
9282 Descriptor* descriptor, 9295 Descriptor* descriptor,
9283 TransitionFlag flag) { 9296 TransitionFlag flag) {
9284 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 9297 Handle<DescriptorArray> descriptors(map->instance_descriptors());
9285 9298
9286 // Share descriptors only if map owns descriptors and it not an initial map. 9299 // Share descriptors only if map owns descriptors and it not an initial map.
9287 if (flag == INSERT_TRANSITION && map->owns_descriptors() && 9300 if (flag == INSERT_TRANSITION && map->owns_descriptors() &&
9288 !map->GetBackPointer()->IsUndefined() && 9301 !map->GetBackPointer()->IsUndefined(map->GetIsolate()) &&
9289 TransitionArray::CanHaveMoreTransitions(map)) { 9302 TransitionArray::CanHaveMoreTransitions(map)) {
9290 return ShareDescriptor(map, descriptors, descriptor); 9303 return ShareDescriptor(map, descriptors, descriptor);
9291 } 9304 }
9292 9305
9293 int nof = map->NumberOfOwnDescriptors(); 9306 int nof = map->NumberOfOwnDescriptors();
9294 Handle<DescriptorArray> new_descriptors = 9307 Handle<DescriptorArray> new_descriptors =
9295 DescriptorArray::CopyUpTo(descriptors, nof, 1); 9308 DescriptorArray::CopyUpTo(descriptors, nof, 1);
9296 new_descriptors->Append(descriptor); 9309 new_descriptors->Append(descriptor);
9297 9310
9298 Handle<LayoutDescriptor> new_layout_descriptor = 9311 Handle<LayoutDescriptor> new_layout_descriptor =
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
10017 return true; 10030 return true;
10018 } 10031 }
10019 10032
10020 10033
10021 // static 10034 // static
10022 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) { 10035 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) {
10023 if (name->IsString()) return Handle<String>::cast(name); 10036 if (name->IsString()) return Handle<String>::cast(name);
10024 // ES6 section 9.2.11 SetFunctionName, step 4. 10037 // ES6 section 9.2.11 SetFunctionName, step 4.
10025 Isolate* const isolate = name->GetIsolate(); 10038 Isolate* const isolate = name->GetIsolate();
10026 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate); 10039 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate);
10027 if (description->IsUndefined()) return isolate->factory()->empty_string(); 10040 if (description->IsUndefined(isolate)) {
10041 return isolate->factory()->empty_string();
10042 }
10028 IncrementalStringBuilder builder(isolate); 10043 IncrementalStringBuilder builder(isolate);
10029 builder.AppendCharacter('['); 10044 builder.AppendCharacter('[');
10030 builder.AppendString(Handle<String>::cast(description)); 10045 builder.AppendString(Handle<String>::cast(description));
10031 builder.AppendCharacter(']'); 10046 builder.AppendCharacter(']');
10032 return builder.Finish(); 10047 return builder.Finish();
10033 } 10048 }
10034 10049
10035 10050
10036 namespace { 10051 namespace {
10037 10052
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
11574 // Visitor id might depend on the instance size, recalculate it. 11589 // Visitor id might depend on the instance size, recalculate it.
11575 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); 11590 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map));
11576 } 11591 }
11577 11592
11578 static void StopSlackTracking(Map* map, void* data) { 11593 static void StopSlackTracking(Map* map, void* data) {
11579 map->set_construction_counter(Map::kNoSlackTracking); 11594 map->set_construction_counter(Map::kNoSlackTracking);
11580 } 11595 }
11581 11596
11582 void Map::CompleteInobjectSlackTracking() { 11597 void Map::CompleteInobjectSlackTracking() {
11583 // Has to be an initial map. 11598 // Has to be an initial map.
11584 DCHECK(GetBackPointer()->IsUndefined()); 11599 DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
11585 11600
11586 int slack = unused_property_fields(); 11601 int slack = unused_property_fields();
11587 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack); 11602 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack);
11588 if (slack != 0) { 11603 if (slack != 0) {
11589 // Resize the initial map and all maps in its transition tree. 11604 // Resize the initial map and all maps in its transition tree.
11590 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); 11605 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack);
11591 } else { 11606 } else {
11592 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr); 11607 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr);
11593 } 11608 }
11594 } 11609 }
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
12386 } 12401 }
12387 12402
12388 int Script::GetEvalPosition() { 12403 int Script::GetEvalPosition() {
12389 DisallowHeapAllocation no_gc; 12404 DisallowHeapAllocation no_gc;
12390 DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL); 12405 DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL);
12391 int position = eval_from_position(); 12406 int position = eval_from_position();
12392 if (position < 0) { 12407 if (position < 0) {
12393 // Due to laziness, the position may not have been translated from code 12408 // Due to laziness, the position may not have been translated from code
12394 // offset yet, which would be encoded as negative integer. In that case, 12409 // offset yet, which would be encoded as negative integer. In that case,
12395 // translate and set the position. 12410 // translate and set the position.
12396 if (eval_from_shared()->IsUndefined()) { 12411 if (eval_from_shared()->IsUndefined(GetIsolate())) {
12397 position = 0; 12412 position = 0;
12398 } else { 12413 } else {
12399 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared()); 12414 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared());
12400 position = shared->abstract_code()->SourcePosition(-position); 12415 position = shared->abstract_code()->SourcePosition(-position);
12401 } 12416 }
12402 DCHECK(position >= 0); 12417 DCHECK(position >= 0);
12403 set_eval_from_position(position); 12418 set_eval_from_position(position);
12404 } 12419 }
12405 return position; 12420 return position;
12406 } 12421 }
12407 12422
12408 void Script::InitLineEnds(Handle<Script> script) { 12423 void Script::InitLineEnds(Handle<Script> script) {
12409 if (!script->line_ends()->IsUndefined()) return;
12410
12411 Isolate* isolate = script->GetIsolate(); 12424 Isolate* isolate = script->GetIsolate();
12425 if (!script->line_ends()->IsUndefined(isolate)) return;
12412 12426
12413 if (!script->source()->IsString()) { 12427 if (!script->source()->IsString()) {
12414 DCHECK(script->source()->IsUndefined()); 12428 DCHECK(script->source()->IsUndefined(isolate));
12415 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0); 12429 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0);
12416 script->set_line_ends(*empty); 12430 script->set_line_ends(*empty);
12417 DCHECK(script->line_ends()->IsFixedArray()); 12431 DCHECK(script->line_ends()->IsFixedArray());
12418 return; 12432 return;
12419 } 12433 }
12420 12434
12421 Handle<String> src(String::cast(script->source()), isolate); 12435 Handle<String> src(String::cast(script->source()), isolate);
12422 12436
12423 Handle<FixedArray> array = String::CalculateLineEnds(src, true); 12437 Handle<FixedArray> array = String::CalculateLineEnds(src, true);
12424 12438
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
12521 12535
12522 12536
12523 int Script::GetLineNumber(Handle<Script> script, int code_pos) { 12537 int Script::GetLineNumber(Handle<Script> script, int code_pos) {
12524 InitLineEnds(script); 12538 InitLineEnds(script);
12525 return script->GetLineNumberWithArray(code_pos); 12539 return script->GetLineNumberWithArray(code_pos);
12526 } 12540 }
12527 12541
12528 12542
12529 int Script::GetLineNumber(int code_pos) { 12543 int Script::GetLineNumber(int code_pos) {
12530 DisallowHeapAllocation no_allocation; 12544 DisallowHeapAllocation no_allocation;
12531 if (!line_ends()->IsUndefined()) return GetLineNumberWithArray(code_pos); 12545 if (!line_ends()->IsUndefined(GetIsolate())) {
12546 return GetLineNumberWithArray(code_pos);
12547 }
12532 12548
12533 // Slow mode: we do not have line_ends. We have to iterate through source. 12549 // Slow mode: we do not have line_ends. We have to iterate through source.
12534 if (!source()->IsString()) return -1; 12550 if (!source()->IsString()) return -1;
12535 12551
12536 String* source_string = String::cast(source()); 12552 String* source_string = String::cast(source());
12537 int line = 0; 12553 int line = 0;
12538 int len = source_string->length(); 12554 int len = source_string->length();
12539 for (int pos = 0; pos < len; pos++) { 12555 for (int pos = 0; pos < len; pos++) {
12540 if (pos == code_pos) break; 12556 if (pos == code_pos) break;
12541 if (source_string->Get(pos) == '\n') line++; 12557 if (source_string->Get(pos) == '\n') line++;
(...skipping 18 matching lines...) Expand all
12560 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL) 12576 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL)
12561 .ToHandle(&result)) { 12577 .ToHandle(&result)) {
12562 return isolate->factory()->undefined_value(); 12578 return isolate->factory()->undefined_value();
12563 } 12579 }
12564 return result; 12580 return result;
12565 } 12581 }
12566 12582
12567 12583
12568 Handle<JSObject> Script::GetWrapper(Handle<Script> script) { 12584 Handle<JSObject> Script::GetWrapper(Handle<Script> script) {
12569 Isolate* isolate = script->GetIsolate(); 12585 Isolate* isolate = script->GetIsolate();
12570 if (!script->wrapper()->IsUndefined()) { 12586 if (!script->wrapper()->IsUndefined(isolate)) {
12571 DCHECK(script->wrapper()->IsWeakCell()); 12587 DCHECK(script->wrapper()->IsWeakCell());
12572 Handle<WeakCell> cell(WeakCell::cast(script->wrapper())); 12588 Handle<WeakCell> cell(WeakCell::cast(script->wrapper()));
12573 if (!cell->cleared()) { 12589 if (!cell->cleared()) {
12574 // Return a handle for the existing script wrapper from the cache. 12590 // Return a handle for the existing script wrapper from the cache.
12575 return handle(JSObject::cast(cell->value())); 12591 return handle(JSObject::cast(cell->value()));
12576 } 12592 }
12577 // If we found an empty WeakCell, that means the script wrapper was 12593 // 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 12594 // 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. 12595 // so that we at least don't count double for any given script.
12580 isolate->counters()->script_wrappers()->Decrement(); 12596 isolate->counters()->script_wrappers()->Decrement();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
12725 return true; 12741 return true;
12726 } 12742 }
12727 if (filter[filter.length() - 1] == '*' && 12743 if (filter[filter.length() - 1] == '*' &&
12728 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { 12744 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
12729 return true; 12745 return true;
12730 } 12746 }
12731 return false; 12747 return false;
12732 } 12748 }
12733 12749
12734 bool SharedFunctionInfo::HasSourceCode() const { 12750 bool SharedFunctionInfo::HasSourceCode() const {
12735 return !script()->IsUndefined() && 12751 Isolate* isolate = GetIsolate();
12736 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); 12752 return !script()->IsUndefined(isolate) &&
12753 !reinterpret_cast<Script*>(script())->source()->IsUndefined(isolate);
12737 } 12754 }
12738 12755
12739 12756
12740 Handle<Object> SharedFunctionInfo::GetSourceCode() { 12757 Handle<Object> SharedFunctionInfo::GetSourceCode() {
12741 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); 12758 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value();
12742 Handle<String> source(String::cast(Script::cast(script())->source())); 12759 Handle<String> source(String::cast(Script::cast(script())->source()));
12743 return GetIsolate()->factory()->NewSubString( 12760 return GetIsolate()->factory()->NewSubString(
12744 source, start_position(), end_position()); 12761 source, start_position(), end_position());
12745 } 12762 }
12746 12763
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
14045 14062
14046 for (uint32_t i = 0; i < back_edges.length(); i++) { 14063 for (uint32_t i = 0; i < back_edges.length(); i++) {
14047 os << std::setw(6) << back_edges.ast_id(i).ToInt() << " " 14064 os << std::setw(6) << back_edges.ast_id(i).ToInt() << " "
14048 << std::setw(9) << back_edges.pc_offset(i) << " " << std::setw(10) 14065 << std::setw(9) << back_edges.pc_offset(i) << " " << std::setw(10)
14049 << back_edges.loop_depth(i) << "\n"; 14066 << back_edges.loop_depth(i) << "\n";
14050 } 14067 }
14051 14068
14052 os << "\n"; 14069 os << "\n";
14053 } 14070 }
14054 #ifdef OBJECT_PRINT 14071 #ifdef OBJECT_PRINT
14055 if (!type_feedback_info()->IsUndefined()) { 14072 if (!type_feedback_info()->IsUndefined(GetIsolate())) {
14056 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); 14073 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os);
14057 os << "\n"; 14074 os << "\n";
14058 } 14075 }
14059 #endif 14076 #endif
14060 } 14077 }
14061 14078
14062 if (handler_table()->length() > 0) { 14079 if (handler_table()->length() > 0) {
14063 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; 14080 os << "Handler Table (size = " << handler_table()->Size() << ")\n";
14064 if (kind() == FUNCTION) { 14081 if (kind() == FUNCTION) {
14065 HandlerTable::cast(handler_table())->HandlerTableRangePrint(os); 14082 HandlerTable::cast(handler_table())->HandlerTableRangePrint(os);
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
14517 } 14534 }
14518 // 5. Let target be the value of the [[ProxyTarget]] internal slot. 14535 // 5. Let target be the value of the [[ProxyTarget]] internal slot.
14519 Handle<JSReceiver> target(proxy->target(), isolate); 14536 Handle<JSReceiver> target(proxy->target(), isolate);
14520 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). 14537 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf").
14521 Handle<Object> trap; 14538 Handle<Object> trap;
14522 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 14539 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
14523 isolate, trap, 14540 isolate, trap,
14524 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), 14541 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
14525 Nothing<bool>()); 14542 Nothing<bool>());
14526 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). 14543 // 7. If trap is undefined, then return target.[[SetPrototypeOf]]().
14527 if (trap->IsUndefined()) { 14544 if (trap->IsUndefined(isolate)) {
14528 return JSReceiver::SetPrototype(target, value, from_javascript, 14545 return JSReceiver::SetPrototype(target, value, from_javascript,
14529 should_throw); 14546 should_throw);
14530 } 14547 }
14531 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). 14548 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)).
14532 Handle<Object> argv[] = {target, value}; 14549 Handle<Object> argv[] = {target, value};
14533 Handle<Object> trap_result; 14550 Handle<Object> trap_result;
14534 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 14551 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
14535 isolate, trap_result, 14552 isolate, trap_result,
14536 Execution::Call(isolate, trap, handler, arraysize(argv), argv), 14553 Execution::Call(isolate, trap, handler, arraysize(argv), argv),
14537 Nothing<bool>()); 14554 Nothing<bool>());
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
15160 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, 15177 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
15161 bool* done) { 15178 bool* done) {
15162 *done = false; 15179 *done = false;
15163 Isolate* isolate = it->isolate(); 15180 Isolate* isolate = it->isolate();
15164 // Make sure that the top context does not change when doing callbacks or 15181 // Make sure that the top context does not change when doing callbacks or
15165 // interceptor calls. 15182 // interceptor calls.
15166 AssertNoContextChange ncc(isolate); 15183 AssertNoContextChange ncc(isolate);
15167 15184
15168 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 15185 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
15169 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); 15186 Handle<InterceptorInfo> interceptor = it->GetInterceptor();
15170 if (interceptor->getter()->IsUndefined()) { 15187 if (interceptor->getter()->IsUndefined(isolate)) {
15171 return isolate->factory()->undefined_value(); 15188 return isolate->factory()->undefined_value();
15172 } 15189 }
15173 15190
15174 Handle<JSObject> holder = it->GetHolder<JSObject>(); 15191 Handle<JSObject> holder = it->GetHolder<JSObject>();
15175 Handle<Object> result; 15192 Handle<Object> result;
15176 Handle<Object> receiver = it->GetReceiver(); 15193 Handle<Object> receiver = it->GetReceiver();
15177 if (!receiver->IsJSReceiver()) { 15194 if (!receiver->IsJSReceiver()) {
15178 ASSIGN_RETURN_ON_EXCEPTION( 15195 ASSIGN_RETURN_ON_EXCEPTION(
15179 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object); 15196 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object);
15180 } 15197 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
15419 #define SYMBOL_CHECK_AND_PRINT(name) \ 15436 #define SYMBOL_CHECK_AND_PRINT(name) \
15420 if (this == heap->name()) return #name; 15437 if (this == heap->name()) return #name;
15421 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT) 15438 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT)
15422 #undef SYMBOL_CHECK_AND_PRINT 15439 #undef SYMBOL_CHECK_AND_PRINT
15423 return "UNKNOWN"; 15440 return "UNKNOWN";
15424 } 15441 }
15425 15442
15426 15443
15427 void Symbol::SymbolShortPrint(std::ostream& os) { 15444 void Symbol::SymbolShortPrint(std::ostream& os) {
15428 os << "<Symbol:"; 15445 os << "<Symbol:";
15429 if (!name()->IsUndefined()) { 15446 if (!name()->IsUndefined(GetIsolate())) {
15430 os << " "; 15447 os << " ";
15431 HeapStringAllocator allocator; 15448 HeapStringAllocator allocator;
15432 StringStream accumulator(&allocator); 15449 StringStream accumulator(&allocator);
15433 String::cast(name())->StringShortPrint(&accumulator, false); 15450 String::cast(name())->StringShortPrint(&accumulator, false);
15434 os << accumulator.ToCString().get(); 15451 os << accumulator.ToCString().get();
15435 } else { 15452 } else {
15436 os << " (" << PrivateSymbolToName() << ")"; 15453 os << " (" << PrivateSymbolToName() << ")";
15437 } 15454 }
15438 os << ">"; 15455 os << ">";
15439 } 15456 }
(...skipping 416 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. 15873 // 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 15874 // In case of positive result the dictionary key may be replaced by the
15858 // internalized string with minimal performance penalty. It gives a chance 15875 // internalized string with minimal performance penalty. It gives a chance
15859 // to perform further lookups in code stubs (and significant performance 15876 // to perform further lookups in code stubs (and significant performance
15860 // boost a certain style of code). 15877 // boost a certain style of code).
15861 15878
15862 // EnsureCapacity will guarantee the hash table is never full. 15879 // EnsureCapacity will guarantee the hash table is never full.
15863 uint32_t capacity = this->Capacity(); 15880 uint32_t capacity = this->Capacity();
15864 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); 15881 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity);
15865 uint32_t count = 1; 15882 uint32_t count = 1;
15866 15883 Isolate* isolate = this->GetIsolate();
15867 while (true) { 15884 while (true) {
15868 int index = Derived::EntryToIndex(entry); 15885 int index = Derived::EntryToIndex(entry);
15869 Object* element = this->get(index); 15886 Object* element = this->get(index);
15870 if (element->IsUndefined()) break; // Empty entry. 15887 if (element->IsUndefined(isolate)) break; // Empty entry.
15871 if (*key == element) return entry; 15888 if (*key == element) return entry;
15872 if (!element->IsUniqueName() && 15889 if (!element->IsUniqueName() && !element->IsTheHole(isolate) &&
15873 !element->IsTheHole() &&
15874 Name::cast(element)->Equals(*key)) { 15890 Name::cast(element)->Equals(*key)) {
15875 // Replace a key that is a non-internalized string by the equivalent 15891 // Replace a key that is a non-internalized string by the equivalent
15876 // internalized string for faster further lookups. 15892 // internalized string for faster further lookups.
15877 this->set(index, *key); 15893 this->set(index, *key);
15878 return entry; 15894 return entry;
15879 } 15895 }
15880 DCHECK(element->IsTheHole() || !Name::cast(element)->Equals(*key)); 15896 DCHECK(element->IsTheHole(isolate) || !Name::cast(element)->Equals(*key));
15881 entry = Derived::NextProbe(entry, count++, capacity); 15897 entry = Derived::NextProbe(entry, count++, capacity);
15882 } 15898 }
15883 return Derived::kNotFound; 15899 return Derived::kNotFound;
15884 } 15900 }
15885 15901
15886 15902
15887 template<typename Derived, typename Shape, typename Key> 15903 template<typename Derived, typename Shape, typename Key>
15888 void HashTable<Derived, Shape, Key>::Rehash( 15904 void HashTable<Derived, Shape, Key>::Rehash(
15889 Handle<Derived> new_table, 15905 Handle<Derived> new_table,
15890 Key key) { 15906 Key key) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
16290 Handle<Object> value(dict->ValueAt(i), isolate); 16306 Handle<Object> value(dict->ValueAt(i), isolate);
16291 PropertyDetails details = dict->DetailsAt(i); 16307 PropertyDetails details = dict->DetailsAt(i);
16292 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) { 16308 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) {
16293 // Bail out and do the sorting of undefineds and array holes in JS. 16309 // 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. 16310 // Also bail out if the element is not supposed to be moved.
16295 return bailout; 16311 return bailout;
16296 } 16312 }
16297 16313
16298 uint32_t key = NumberToUint32(k); 16314 uint32_t key = NumberToUint32(k);
16299 if (key < limit) { 16315 if (key < limit) {
16300 if (value->IsUndefined()) { 16316 if (value->IsUndefined(isolate)) {
16301 undefs++; 16317 undefs++;
16302 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { 16318 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) {
16303 // Adding an entry with the key beyond smi-range requires 16319 // Adding an entry with the key beyond smi-range requires
16304 // allocation. Bailout. 16320 // allocation. Bailout.
16305 return bailout; 16321 return bailout;
16306 } else { 16322 } else {
16307 Handle<Object> result = SeededNumberDictionary::AddNumberEntry( 16323 Handle<Object> result = SeededNumberDictionary::AddNumberEntry(
16308 new_dict, pos, value, details, object->map()->is_prototype_map()); 16324 new_dict, pos, value, details, object->map()->is_prototype_map());
16309 DCHECK(result.is_identical_to(new_dict)); 16325 DCHECK(result.is_identical_to(new_dict));
16310 USE(result); 16326 USE(result);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
16440 16456
16441 // Split elements into defined, undefined and the_hole, in that order. Only 16457 // Split elements into defined, undefined and the_hole, in that order. Only
16442 // count locations for undefined and the hole, and fill them afterwards. 16458 // count locations for undefined and the hole, and fill them afterwards.
16443 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc); 16459 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc);
16444 unsigned int undefs = limit; 16460 unsigned int undefs = limit;
16445 unsigned int holes = limit; 16461 unsigned int holes = limit;
16446 // Assume most arrays contain no holes and undefined values, so minimize the 16462 // Assume most arrays contain no holes and undefined values, so minimize the
16447 // number of stores of non-undefined, non-the-hole values. 16463 // number of stores of non-undefined, non-the-hole values.
16448 for (unsigned int i = 0; i < undefs; i++) { 16464 for (unsigned int i = 0; i < undefs; i++) {
16449 Object* current = elements->get(i); 16465 Object* current = elements->get(i);
16450 if (current->IsTheHole()) { 16466 if (current->IsTheHole(isolate)) {
16451 holes--; 16467 holes--;
16452 undefs--; 16468 undefs--;
16453 } else if (current->IsUndefined()) { 16469 } else if (current->IsUndefined(isolate)) {
16454 undefs--; 16470 undefs--;
16455 } else { 16471 } else {
16456 continue; 16472 continue;
16457 } 16473 }
16458 // Position i needs to be filled. 16474 // Position i needs to be filled.
16459 while (undefs > i) { 16475 while (undefs > i) {
16460 current = elements->get(undefs); 16476 current = elements->get(undefs);
16461 if (current->IsTheHole()) { 16477 if (current->IsTheHole(isolate)) {
16462 holes--; 16478 holes--;
16463 undefs--; 16479 undefs--;
16464 } else if (current->IsUndefined()) { 16480 } else if (current->IsUndefined(isolate)) {
16465 undefs--; 16481 undefs--;
16466 } else { 16482 } else {
16467 elements->set(i, current, write_barrier); 16483 elements->set(i, current, write_barrier);
16468 break; 16484 break;
16469 } 16485 }
16470 } 16486 }
16471 } 16487 }
16472 result = undefs; 16488 result = undefs;
16473 while (undefs < holes) { 16489 while (undefs < holes) {
16474 elements->set_undefined(undefs); 16490 elements->set_undefined(undefs);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
16522 auto dictionary = handle(global->global_dictionary()); 16538 auto dictionary = handle(global->global_dictionary());
16523 int entry = dictionary->FindEntry(name); 16539 int entry = dictionary->FindEntry(name);
16524 if (entry == GlobalDictionary::kNotFound) return; 16540 if (entry == GlobalDictionary::kNotFound) return;
16525 PropertyCell::InvalidateEntry(dictionary, entry); 16541 PropertyCell::InvalidateEntry(dictionary, entry);
16526 } 16542 }
16527 16543
16528 16544
16529 // TODO(ishell): rename to EnsureEmptyPropertyCell or something. 16545 // TODO(ishell): rename to EnsureEmptyPropertyCell or something.
16530 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( 16546 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
16531 Handle<JSGlobalObject> global, Handle<Name> name) { 16547 Handle<JSGlobalObject> global, Handle<Name> name) {
16548 Isolate* isolate = global->GetIsolate();
16532 DCHECK(!global->HasFastProperties()); 16549 DCHECK(!global->HasFastProperties());
16533 auto dictionary = handle(global->global_dictionary()); 16550 auto dictionary = handle(global->global_dictionary(), isolate);
16534 int entry = dictionary->FindEntry(name); 16551 int entry = dictionary->FindEntry(name);
16535 Handle<PropertyCell> cell; 16552 Handle<PropertyCell> cell;
16536 if (entry != GlobalDictionary::kNotFound) { 16553 if (entry != GlobalDictionary::kNotFound) {
16537 // This call should be idempotent. 16554 // This call should be idempotent.
16538 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); 16555 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
16539 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); 16556 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry)));
16540 DCHECK(cell->property_details().cell_type() == 16557 DCHECK(cell->property_details().cell_type() ==
16541 PropertyCellType::kUninitialized || 16558 PropertyCellType::kUninitialized ||
16542 cell->property_details().cell_type() == 16559 cell->property_details().cell_type() ==
16543 PropertyCellType::kInvalidated); 16560 PropertyCellType::kInvalidated);
16544 DCHECK(cell->value()->IsTheHole()); 16561 DCHECK(cell->value()->IsTheHole(isolate));
16545 return cell; 16562 return cell;
16546 } 16563 }
16547 Isolate* isolate = global->GetIsolate();
16548 cell = isolate->factory()->NewPropertyCell(); 16564 cell = isolate->factory()->NewPropertyCell();
16549 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); 16565 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized);
16550 dictionary = GlobalDictionary::Add(dictionary, name, cell, details); 16566 dictionary = GlobalDictionary::Add(dictionary, name, cell, details);
16551 global->set_properties(*dictionary); 16567 global->set_properties(*dictionary);
16552 return cell; 16568 return cell;
16553 } 16569 }
16554 16570
16555 16571
16556 // This class is used for looking up two character strings in the string table. 16572 // This class is used for looking up two character strings in the string table.
16557 // If we don't have a hit we don't want to waste much time so we unroll the 16573 // If we don't have a hit we don't want to waste much time so we unroll the
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
17321 17337
17322 17338
17323 Object* ObjectHashTable::Lookup(Handle<Object> key) { 17339 Object* ObjectHashTable::Lookup(Handle<Object> key) {
17324 DisallowHeapAllocation no_gc; 17340 DisallowHeapAllocation no_gc;
17325 DCHECK(IsKey(*key)); 17341 DCHECK(IsKey(*key));
17326 17342
17327 Isolate* isolate = GetIsolate(); 17343 Isolate* isolate = GetIsolate();
17328 17344
17329 // If the object does not have an identity hash, it was never used as a key. 17345 // If the object does not have an identity hash, it was never used as a key.
17330 Object* hash = key->GetHash(); 17346 Object* hash = key->GetHash();
17331 if (hash->IsUndefined()) { 17347 if (hash->IsUndefined(isolate)) {
17332 return isolate->heap()->the_hole_value(); 17348 return isolate->heap()->the_hole_value();
17333 } 17349 }
17334 return Lookup(isolate, key, Smi::cast(hash)->value()); 17350 return Lookup(isolate, key, Smi::cast(hash)->value());
17335 } 17351 }
17336 17352
17337 17353
17338 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) { 17354 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) {
17339 return Lookup(GetIsolate(), key, hash); 17355 return Lookup(GetIsolate(), key, hash);
17340 } 17356 }
17341 17357
17342 17358
17343 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, 17359 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
17344 Handle<Object> key, 17360 Handle<Object> key,
17345 Handle<Object> value) { 17361 Handle<Object> value) {
17362 Isolate* isolate = table->GetIsolate();
17363
17346 DCHECK(table->IsKey(*key)); 17364 DCHECK(table->IsKey(*key));
17347 DCHECK(!value->IsTheHole()); 17365 DCHECK(!value->IsTheHole(isolate));
17348 17366
17349 Isolate* isolate = table->GetIsolate();
17350 // Make sure the key object has an identity hash code. 17367 // Make sure the key object has an identity hash code.
17351 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 17368 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
17352 17369
17353 return Put(table, key, value, hash); 17370 return Put(table, key, value, hash);
17354 } 17371 }
17355 17372
17356 17373
17357 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, 17374 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
17358 Handle<Object> key, 17375 Handle<Object> key,
17359 Handle<Object> value, 17376 Handle<Object> value,
17360 int32_t hash) { 17377 int32_t hash) {
17378 Isolate* isolate = table->GetIsolate();
17379
17361 DCHECK(table->IsKey(*key)); 17380 DCHECK(table->IsKey(*key));
17362 DCHECK(!value->IsTheHole()); 17381 DCHECK(!value->IsTheHole(isolate));
17363
17364 Isolate* isolate = table->GetIsolate();
17365 17382
17366 int entry = table->FindEntry(isolate, key, hash); 17383 int entry = table->FindEntry(isolate, key, hash);
17367 17384
17368 // Key is already in table, just overwrite value. 17385 // Key is already in table, just overwrite value.
17369 if (entry != kNotFound) { 17386 if (entry != kNotFound) {
17370 table->set(EntryToIndex(entry) + 1, *value); 17387 table->set(EntryToIndex(entry) + 1, *value);
17371 return table; 17388 return table;
17372 } 17389 }
17373 17390
17374 // Rehash if more than 33% of the entries are deleted entries. 17391 // Rehash if more than 33% of the entries are deleted entries.
17375 // TODO(jochen): Consider to shrink the fixed array in place. 17392 // TODO(jochen): Consider to shrink the fixed array in place.
17376 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { 17393 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
17377 table->Rehash(isolate->factory()->undefined_value()); 17394 table->Rehash(isolate->factory()->undefined_value());
17378 } 17395 }
17379 17396
17380 // Check whether the hash table should be extended. 17397 // Check whether the hash table should be extended.
17381 table = EnsureCapacity(table, 1, key); 17398 table = EnsureCapacity(table, 1, key);
17382 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); 17399 table->AddEntry(table->FindInsertionEntry(hash), *key, *value);
17383 return table; 17400 return table;
17384 } 17401 }
17385 17402
17386 17403
17387 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, 17404 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table,
17388 Handle<Object> key, 17405 Handle<Object> key,
17389 bool* was_present) { 17406 bool* was_present) {
17390 DCHECK(table->IsKey(*key)); 17407 DCHECK(table->IsKey(*key));
17391 17408
17392 Object* hash = key->GetHash(); 17409 Object* hash = key->GetHash();
17393 if (hash->IsUndefined()) { 17410 if (hash->IsUndefined(table->GetIsolate())) {
17394 *was_present = false; 17411 *was_present = false;
17395 return table; 17412 return table;
17396 } 17413 }
17397 17414
17398 return Remove(table, key, was_present, Smi::cast(hash)->value()); 17415 return Remove(table, key, was_present, Smi::cast(hash)->value());
17399 } 17416 }
17400 17417
17401 17418
17402 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, 17419 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table,
17403 Handle<Object> key, 17420 Handle<Object> key,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
17614 17631
17615 Handle<Derived> new_table = Allocate( 17632 Handle<Derived> new_table = Allocate(
17616 isolate, new_capacity, heap->InNewSpace(*table) ? NOT_TENURED : TENURED); 17633 isolate, new_capacity, heap->InNewSpace(*table) ? NOT_TENURED : TENURED);
17617 int nof = table->NumberOfElements(); 17634 int nof = table->NumberOfElements();
17618 int nod = table->NumberOfDeletedElements(); 17635 int nod = table->NumberOfDeletedElements();
17619 int new_buckets = new_table->NumberOfBuckets(); 17636 int new_buckets = new_table->NumberOfBuckets();
17620 int new_entry = 0; 17637 int new_entry = 0;
17621 int removed_holes_index = 0; 17638 int removed_holes_index = 0;
17622 17639
17623 DisallowHeapAllocation no_gc; 17640 DisallowHeapAllocation no_gc;
17624 Object* the_hole = heap->the_hole_value();
17625 for (int old_entry = 0; old_entry < (nof + nod); ++old_entry) { 17641 for (int old_entry = 0; old_entry < (nof + nod); ++old_entry) {
17626 Object* key = table->KeyAt(old_entry); 17642 Object* key = table->KeyAt(old_entry);
17627 if (key == the_hole) { 17643 if (key->IsTheHole(isolate)) {
17628 table->SetRemovedIndexAt(removed_holes_index++, old_entry); 17644 table->SetRemovedIndexAt(removed_holes_index++, old_entry);
17629 continue; 17645 continue;
17630 } 17646 }
17631 17647
17632 Object* hash = key->GetHash(); 17648 Object* hash = key->GetHash();
17633 int bucket = Smi::cast(hash)->value() & (new_buckets - 1); 17649 int bucket = Smi::cast(hash)->value() & (new_buckets - 1);
17634 Object* chain_entry = new_table->get(kHashTableStartIndex + bucket); 17650 Object* chain_entry = new_table->get(kHashTableStartIndex + bucket);
17635 new_table->set(kHashTableStartIndex + bucket, Smi::FromInt(new_entry)); 17651 new_table->set(kHashTableStartIndex + bucket, Smi::FromInt(new_entry));
17636 int new_index = new_table->EntryToIndex(new_entry); 17652 int new_index = new_table->EntryToIndex(new_entry);
17637 int old_index = table->EntryToIndex(old_entry); 17653 int old_index = table->EntryToIndex(old_entry);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
17721 } 17737 }
17722 17738
17723 set_table(table); 17739 set_table(table);
17724 set_index(Smi::FromInt(index)); 17740 set_index(Smi::FromInt(index));
17725 } 17741 }
17726 17742
17727 17743
17728 template<class Derived, class TableType> 17744 template<class Derived, class TableType>
17729 bool OrderedHashTableIterator<Derived, TableType>::HasMore() { 17745 bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
17730 DisallowHeapAllocation no_allocation; 17746 DisallowHeapAllocation no_allocation;
17731 if (this->table()->IsUndefined()) return false; 17747 Isolate* isolate = this->GetIsolate();
17748 if (this->table()->IsUndefined(isolate)) return false;
17732 17749
17733 Transition(); 17750 Transition();
17734 17751
17735 TableType* table = TableType::cast(this->table()); 17752 TableType* table = TableType::cast(this->table());
17736 int index = Smi::cast(this->index())->value(); 17753 int index = Smi::cast(this->index())->value();
17737 int used_capacity = table->UsedCapacity(); 17754 int used_capacity = table->UsedCapacity();
17738 17755
17739 while (index < used_capacity && table->KeyAt(index)->IsTheHole()) { 17756 while (index < used_capacity && table->KeyAt(index)->IsTheHole(isolate)) {
17740 index++; 17757 index++;
17741 } 17758 }
17742 17759
17743 set_index(Smi::FromInt(index)); 17760 set_index(Smi::FromInt(index));
17744 17761
17745 if (index < used_capacity) return true; 17762 if (index < used_capacity) return true;
17746 17763
17747 set_table(GetHeap()->undefined_value()); 17764 set_table(isolate->heap()->undefined_value());
17748 return false; 17765 return false;
17749 } 17766 }
17750 17767
17751 17768
17752 template<class Derived, class TableType> 17769 template<class Derived, class TableType>
17753 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { 17770 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) {
17754 DisallowHeapAllocation no_allocation; 17771 DisallowHeapAllocation no_allocation;
17755 if (HasMore()) { 17772 if (HasMore()) {
17756 FixedArray* array = FixedArray::cast(value_array->elements()); 17773 FixedArray* array = FixedArray::cast(value_array->elements());
17757 static_cast<Derived*>(this)->PopulateValueArray(array); 17774 static_cast<Derived*>(this)->PopulateValueArray(array);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
17863 return was_present; 17880 return was_present;
17864 } 17881 }
17865 17882
17866 // Check if there is a break point at this code offset. 17883 // Check if there is a break point at this code offset.
17867 bool DebugInfo::HasBreakPoint(int code_offset) { 17884 bool DebugInfo::HasBreakPoint(int code_offset) {
17868 // Get the break point info object for this code offset. 17885 // Get the break point info object for this code offset.
17869 Object* break_point_info = GetBreakPointInfo(code_offset); 17886 Object* break_point_info = GetBreakPointInfo(code_offset);
17870 17887
17871 // If there is no break point info object or no break points in the break 17888 // If there is no break point info object or no break points in the break
17872 // point info object there is no break point at this code offset. 17889 // point info object there is no break point at this code offset.
17873 if (break_point_info->IsUndefined()) return false; 17890 if (break_point_info->IsUndefined(GetIsolate())) return false;
17874 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; 17891 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
17875 } 17892 }
17876 17893
17877 // Get the break point info object for this code offset. 17894 // Get the break point info object for this code offset.
17878 Object* DebugInfo::GetBreakPointInfo(int code_offset) { 17895 Object* DebugInfo::GetBreakPointInfo(int code_offset) {
17879 // Find the index of the break point info object for this code offset. 17896 // Find the index of the break point info object for this code offset.
17880 int index = GetBreakPointInfoIndex(code_offset); 17897 int index = GetBreakPointInfoIndex(code_offset);
17881 17898
17882 // Return the break point info object if any. 17899 // Return the break point info object if any.
17883 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); 17900 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value();
17884 return BreakPointInfo::cast(break_points()->get(index)); 17901 return BreakPointInfo::cast(break_points()->get(index));
17885 } 17902 }
17886 17903
17887 // Clear a break point at the specified code offset. 17904 // Clear a break point at the specified code offset.
17888 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, 17905 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
17889 Handle<Object> break_point_object) { 17906 Handle<Object> break_point_object) {
17907 Isolate* isolate = debug_info->GetIsolate();
17890 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), 17908 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset),
17891 debug_info->GetIsolate()); 17909 isolate);
17892 if (break_point_info->IsUndefined()) return; 17910 if (break_point_info->IsUndefined(isolate)) return;
17893 BreakPointInfo::ClearBreakPoint( 17911 BreakPointInfo::ClearBreakPoint(
17894 Handle<BreakPointInfo>::cast(break_point_info), 17912 Handle<BreakPointInfo>::cast(break_point_info),
17895 break_point_object); 17913 break_point_object);
17896 } 17914 }
17897 17915
17898 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, 17916 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
17899 int source_position, int statement_position, 17917 int source_position, int statement_position,
17900 Handle<Object> break_point_object) { 17918 Handle<Object> break_point_object) {
17901 Isolate* isolate = debug_info->GetIsolate(); 17919 Isolate* isolate = debug_info->GetIsolate();
17902 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), 17920 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset),
17903 isolate); 17921 isolate);
17904 if (!break_point_info->IsUndefined()) { 17922 if (!break_point_info->IsUndefined(isolate)) {
17905 BreakPointInfo::SetBreakPoint( 17923 BreakPointInfo::SetBreakPoint(
17906 Handle<BreakPointInfo>::cast(break_point_info), 17924 Handle<BreakPointInfo>::cast(break_point_info),
17907 break_point_object); 17925 break_point_object);
17908 return; 17926 return;
17909 } 17927 }
17910 17928
17911 // Adding a new break point for a code offset which did not have any 17929 // Adding a new break point for a code offset which did not have any
17912 // break points before. Try to find a free slot. 17930 // break points before. Try to find a free slot.
17913 int index = kNoBreakPointInfo; 17931 int index = kNoBreakPointInfo;
17914 for (int i = 0; i < debug_info->break_points()->length(); i++) { 17932 for (int i = 0; i < debug_info->break_points()->length(); i++) {
17915 if (debug_info->break_points()->get(i)->IsUndefined()) { 17933 if (debug_info->break_points()->get(i)->IsUndefined(isolate)) {
17916 index = i; 17934 index = i;
17917 break; 17935 break;
17918 } 17936 }
17919 } 17937 }
17920 if (index == kNoBreakPointInfo) { 17938 if (index == kNoBreakPointInfo) {
17921 // No free slot - extend break point info array. 17939 // No free slot - extend break point info array.
17922 Handle<FixedArray> old_break_points = 17940 Handle<FixedArray> old_break_points = Handle<FixedArray>(
17923 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); 17941 FixedArray::cast(debug_info->break_points()), isolate);
17924 Handle<FixedArray> new_break_points = 17942 Handle<FixedArray> new_break_points =
17925 isolate->factory()->NewFixedArray( 17943 isolate->factory()->NewFixedArray(
17926 old_break_points->length() + 17944 old_break_points->length() +
17927 DebugInfo::kEstimatedNofBreakPointsInFunction); 17945 DebugInfo::kEstimatedNofBreakPointsInFunction);
17928 17946
17929 debug_info->set_break_points(*new_break_points); 17947 debug_info->set_break_points(*new_break_points);
17930 for (int i = 0; i < old_break_points->length(); i++) { 17948 for (int i = 0; i < old_break_points->length(); i++) {
17931 new_break_points->set(i, old_break_points->get(i)); 17949 new_break_points->set(i, old_break_points->get(i));
17932 } 17950 }
17933 index = old_break_points->length(); 17951 index = old_break_points->length();
17934 } 17952 }
17935 DCHECK(index != kNoBreakPointInfo); 17953 DCHECK(index != kNoBreakPointInfo);
17936 17954
17937 // Allocate new BreakPointInfo object and set the break point. 17955 // Allocate new BreakPointInfo object and set the break point.
17938 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( 17956 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
17939 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); 17957 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE));
17940 new_break_point_info->set_code_offset(code_offset); 17958 new_break_point_info->set_code_offset(code_offset);
17941 new_break_point_info->set_source_position(source_position); 17959 new_break_point_info->set_source_position(source_position);
17942 new_break_point_info->set_statement_position(statement_position); 17960 new_break_point_info->set_statement_position(statement_position);
17943 new_break_point_info->set_break_point_objects( 17961 new_break_point_info->set_break_point_objects(
17944 isolate->heap()->undefined_value()); 17962 isolate->heap()->undefined_value());
17945 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); 17963 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
17946 debug_info->break_points()->set(index, *new_break_point_info); 17964 debug_info->break_points()->set(index, *new_break_point_info);
17947 } 17965 }
17948 17966
17949 // Get the break point objects for a code offset. 17967 // Get the break point objects for a code offset.
17950 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { 17968 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) {
17951 Object* break_point_info = GetBreakPointInfo(code_offset); 17969 Object* break_point_info = GetBreakPointInfo(code_offset);
17952 if (break_point_info->IsUndefined()) { 17970 Isolate* isolate = GetIsolate();
17953 return GetIsolate()->factory()->undefined_value(); 17971 if (break_point_info->IsUndefined(isolate)) {
17972 return isolate->factory()->undefined_value();
17954 } 17973 }
17955 return Handle<Object>( 17974 return Handle<Object>(
17956 BreakPointInfo::cast(break_point_info)->break_point_objects(), 17975 BreakPointInfo::cast(break_point_info)->break_point_objects(), isolate);
17957 GetIsolate());
17958 } 17976 }
17959 17977
17960 17978
17961 // Get the total number of break points. 17979 // Get the total number of break points.
17962 int DebugInfo::GetBreakPointCount() { 17980 int DebugInfo::GetBreakPointCount() {
17963 if (break_points()->IsUndefined()) return 0; 17981 Isolate* isolate = GetIsolate();
17982 if (break_points()->IsUndefined(isolate)) return 0;
17964 int count = 0; 17983 int count = 0;
17965 for (int i = 0; i < break_points()->length(); i++) { 17984 for (int i = 0; i < break_points()->length(); i++) {
17966 if (!break_points()->get(i)->IsUndefined()) { 17985 if (!break_points()->get(i)->IsUndefined(isolate)) {
17967 BreakPointInfo* break_point_info = 17986 BreakPointInfo* break_point_info =
17968 BreakPointInfo::cast(break_points()->get(i)); 17987 BreakPointInfo::cast(break_points()->get(i));
17969 count += break_point_info->GetBreakPointCount(); 17988 count += break_point_info->GetBreakPointCount();
17970 } 17989 }
17971 } 17990 }
17972 return count; 17991 return count;
17973 } 17992 }
17974 17993
17975 17994
17976 Handle<Object> DebugInfo::FindBreakPointInfo( 17995 Handle<Object> DebugInfo::FindBreakPointInfo(
17977 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) { 17996 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) {
17978 Isolate* isolate = debug_info->GetIsolate(); 17997 Isolate* isolate = debug_info->GetIsolate();
17979 if (!debug_info->break_points()->IsUndefined()) { 17998 if (!debug_info->break_points()->IsUndefined(isolate)) {
17980 for (int i = 0; i < debug_info->break_points()->length(); i++) { 17999 for (int i = 0; i < debug_info->break_points()->length(); i++) {
17981 if (!debug_info->break_points()->get(i)->IsUndefined()) { 18000 if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) {
17982 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>( 18001 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>(
17983 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate); 18002 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate);
17984 if (BreakPointInfo::HasBreakPointObject(break_point_info, 18003 if (BreakPointInfo::HasBreakPointObject(break_point_info,
17985 break_point_object)) { 18004 break_point_object)) {
17986 return break_point_info; 18005 return break_point_info;
17987 } 18006 }
17988 } 18007 }
17989 } 18008 }
17990 } 18009 }
17991 return isolate->factory()->undefined_value(); 18010 return isolate->factory()->undefined_value();
17992 } 18011 }
17993 18012
17994 18013
17995 // Find the index of the break point info object for the specified code 18014 // Find the index of the break point info object for the specified code
17996 // position. 18015 // position.
17997 int DebugInfo::GetBreakPointInfoIndex(int code_offset) { 18016 int DebugInfo::GetBreakPointInfoIndex(int code_offset) {
17998 if (break_points()->IsUndefined()) return kNoBreakPointInfo; 18017 Isolate* isolate = GetIsolate();
18018 if (break_points()->IsUndefined(isolate)) return kNoBreakPointInfo;
17999 for (int i = 0; i < break_points()->length(); i++) { 18019 for (int i = 0; i < break_points()->length(); i++) {
18000 if (!break_points()->get(i)->IsUndefined()) { 18020 if (!break_points()->get(i)->IsUndefined(isolate)) {
18001 BreakPointInfo* break_point_info = 18021 BreakPointInfo* break_point_info =
18002 BreakPointInfo::cast(break_points()->get(i)); 18022 BreakPointInfo::cast(break_points()->get(i));
18003 if (break_point_info->code_offset() == code_offset) { 18023 if (break_point_info->code_offset() == code_offset) {
18004 return i; 18024 return i;
18005 } 18025 }
18006 } 18026 }
18007 } 18027 }
18008 return kNoBreakPointInfo; 18028 return kNoBreakPointInfo;
18009 } 18029 }
18010 18030
18011 18031
18012 // Remove the specified break point object. 18032 // Remove the specified break point object.
18013 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, 18033 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
18014 Handle<Object> break_point_object) { 18034 Handle<Object> break_point_object) {
18015 Isolate* isolate = break_point_info->GetIsolate(); 18035 Isolate* isolate = break_point_info->GetIsolate();
18016 // If there are no break points just ignore. 18036 // If there are no break points just ignore.
18017 if (break_point_info->break_point_objects()->IsUndefined()) return; 18037 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. 18038 // If there is a single break point clear it if it is the same.
18019 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18039 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18020 if (break_point_info->break_point_objects() == *break_point_object) { 18040 if (break_point_info->break_point_objects() == *break_point_object) {
18021 break_point_info->set_break_point_objects( 18041 break_point_info->set_break_point_objects(
18022 isolate->heap()->undefined_value()); 18042 isolate->heap()->undefined_value());
18023 } 18043 }
18024 return; 18044 return;
18025 } 18045 }
18026 // If there are multiple break points shrink the array 18046 // If there are multiple break points shrink the array
18027 DCHECK(break_point_info->break_point_objects()->IsFixedArray()); 18047 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); 18063 if (found_count > 0) break_point_info->set_break_point_objects(*new_array);
18044 } 18064 }
18045 18065
18046 18066
18047 // Add the specified break point object. 18067 // Add the specified break point object.
18048 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info, 18068 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
18049 Handle<Object> break_point_object) { 18069 Handle<Object> break_point_object) {
18050 Isolate* isolate = break_point_info->GetIsolate(); 18070 Isolate* isolate = break_point_info->GetIsolate();
18051 18071
18052 // If there was no break point objects before just set it. 18072 // If there was no break point objects before just set it.
18053 if (break_point_info->break_point_objects()->IsUndefined()) { 18073 if (break_point_info->break_point_objects()->IsUndefined(isolate)) {
18054 break_point_info->set_break_point_objects(*break_point_object); 18074 break_point_info->set_break_point_objects(*break_point_object);
18055 return; 18075 return;
18056 } 18076 }
18057 // If the break point object is the same as before just ignore. 18077 // If the break point object is the same as before just ignore.
18058 if (break_point_info->break_point_objects() == *break_point_object) return; 18078 if (break_point_info->break_point_objects() == *break_point_object) return;
18059 // If there was one break point object before replace with array. 18079 // If there was one break point object before replace with array.
18060 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18080 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18061 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2); 18081 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2);
18062 array->set(0, break_point_info->break_point_objects()); 18082 array->set(0, break_point_info->break_point_objects());
18063 array->set(1, *break_point_object); 18083 array->set(1, *break_point_object);
(...skipping 14 matching lines...) Expand all
18078 // Add the new break point. 18098 // Add the new break point.
18079 new_array->set(old_array->length(), *break_point_object); 18099 new_array->set(old_array->length(), *break_point_object);
18080 break_point_info->set_break_point_objects(*new_array); 18100 break_point_info->set_break_point_objects(*new_array);
18081 } 18101 }
18082 18102
18083 18103
18084 bool BreakPointInfo::HasBreakPointObject( 18104 bool BreakPointInfo::HasBreakPointObject(
18085 Handle<BreakPointInfo> break_point_info, 18105 Handle<BreakPointInfo> break_point_info,
18086 Handle<Object> break_point_object) { 18106 Handle<Object> break_point_object) {
18087 // No break point. 18107 // No break point.
18088 if (break_point_info->break_point_objects()->IsUndefined()) return false; 18108 Isolate* isolate = break_point_info->GetIsolate();
18109 if (break_point_info->break_point_objects()->IsUndefined(isolate)) {
18110 return false;
18111 }
18089 // Single break point. 18112 // Single break point.
18090 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18113 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18091 return break_point_info->break_point_objects() == *break_point_object; 18114 return break_point_info->break_point_objects() == *break_point_object;
18092 } 18115 }
18093 // Multiple break points. 18116 // Multiple break points.
18094 FixedArray* array = FixedArray::cast(break_point_info->break_point_objects()); 18117 FixedArray* array = FixedArray::cast(break_point_info->break_point_objects());
18095 for (int i = 0; i < array->length(); i++) { 18118 for (int i = 0; i < array->length(); i++) {
18096 if (array->get(i) == *break_point_object) { 18119 if (array->get(i) == *break_point_object) {
18097 return true; 18120 return true;
18098 } 18121 }
18099 } 18122 }
18100 return false; 18123 return false;
18101 } 18124 }
18102 18125
18103 18126
18104 // Get the number of break points. 18127 // Get the number of break points.
18105 int BreakPointInfo::GetBreakPointCount() { 18128 int BreakPointInfo::GetBreakPointCount() {
18106 // No break point. 18129 // No break point.
18107 if (break_point_objects()->IsUndefined()) return 0; 18130 if (break_point_objects()->IsUndefined(GetIsolate())) return 0;
18108 // Single break point. 18131 // Single break point.
18109 if (!break_point_objects()->IsFixedArray()) return 1; 18132 if (!break_point_objects()->IsFixedArray()) return 1;
18110 // Multiple break points. 18133 // Multiple break points.
18111 return FixedArray::cast(break_point_objects())->length(); 18134 return FixedArray::cast(break_point_objects())->length();
18112 } 18135 }
18113 18136
18114 18137
18115 // static 18138 // static
18116 MaybeHandle<JSDate> JSDate::New(Handle<JSFunction> constructor, 18139 MaybeHandle<JSDate> JSDate::New(Handle<JSFunction> constructor,
18117 Handle<JSReceiver> new_target, double tv) { 18140 Handle<JSReceiver> new_target, double tv) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
18424 18447
18425 Handle<PropertyCell> PropertyCell::InvalidateEntry( 18448 Handle<PropertyCell> PropertyCell::InvalidateEntry(
18426 Handle<GlobalDictionary> dictionary, int entry) { 18449 Handle<GlobalDictionary> dictionary, int entry) {
18427 Isolate* isolate = dictionary->GetIsolate(); 18450 Isolate* isolate = dictionary->GetIsolate();
18428 // Swap with a copy. 18451 // Swap with a copy.
18429 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); 18452 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
18430 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); 18453 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
18431 auto new_cell = isolate->factory()->NewPropertyCell(); 18454 auto new_cell = isolate->factory()->NewPropertyCell();
18432 new_cell->set_value(cell->value()); 18455 new_cell->set_value(cell->value());
18433 dictionary->ValueAtPut(entry, *new_cell); 18456 dictionary->ValueAtPut(entry, *new_cell);
18434 bool is_the_hole = cell->value()->IsTheHole(); 18457 bool is_the_hole = cell->value()->IsTheHole(isolate);
18435 // Cell is officially mutable henceforth. 18458 // Cell is officially mutable henceforth.
18436 PropertyDetails details = cell->property_details(); 18459 PropertyDetails details = cell->property_details();
18437 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated 18460 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated
18438 : PropertyCellType::kMutable); 18461 : PropertyCellType::kMutable);
18439 new_cell->set_property_details(details); 18462 new_cell->set_property_details(details);
18440 // Old cell is ready for invalidation. 18463 // Old cell is ready for invalidation.
18441 if (is_the_hole) { 18464 if (is_the_hole) {
18442 cell->set_value(isolate->heap()->undefined_value()); 18465 cell->set_value(isolate->heap()->undefined_value());
18443 } else { 18466 } else {
18444 cell->set_value(isolate->heap()->the_hole_value()); 18467 cell->set_value(isolate->heap()->the_hole_value());
(...skipping 23 matching lines...) Expand all
18468 HeapObject::cast(*value)->map()->is_stable(); 18491 HeapObject::cast(*value)->map()->is_stable();
18469 } 18492 }
18470 return false; 18493 return false;
18471 } 18494 }
18472 18495
18473 18496
18474 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell, 18497 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
18475 Handle<Object> value, 18498 Handle<Object> value,
18476 PropertyDetails details) { 18499 PropertyDetails details) {
18477 PropertyCellType type = details.cell_type(); 18500 PropertyCellType type = details.cell_type();
18478 DCHECK(!value->IsTheHole()); 18501 Isolate* isolate = cell->GetIsolate();
18479 if (cell->value()->IsTheHole()) { 18502 DCHECK(!value->IsTheHole(isolate));
18503 if (cell->value()->IsTheHole(isolate)) {
18480 switch (type) { 18504 switch (type) {
18481 // Only allow a cell to transition once into constant state. 18505 // Only allow a cell to transition once into constant state.
18482 case PropertyCellType::kUninitialized: 18506 case PropertyCellType::kUninitialized:
18483 if (value->IsUndefined()) return PropertyCellType::kUndefined; 18507 if (value->IsUndefined(isolate)) return PropertyCellType::kUndefined;
18484 return PropertyCellType::kConstant; 18508 return PropertyCellType::kConstant;
18485 case PropertyCellType::kInvalidated: 18509 case PropertyCellType::kInvalidated:
18486 return PropertyCellType::kMutable; 18510 return PropertyCellType::kMutable;
18487 default: 18511 default:
18488 UNREACHABLE(); 18512 UNREACHABLE();
18489 return PropertyCellType::kMutable; 18513 return PropertyCellType::kMutable;
18490 } 18514 }
18491 } 18515 }
18492 switch (type) { 18516 switch (type) {
18493 case PropertyCellType::kUndefined: 18517 case PropertyCellType::kUndefined:
18494 return PropertyCellType::kConstant; 18518 return PropertyCellType::kConstant;
18495 case PropertyCellType::kConstant: 18519 case PropertyCellType::kConstant:
18496 if (*value == cell->value()) return PropertyCellType::kConstant; 18520 if (*value == cell->value()) return PropertyCellType::kConstant;
18497 // Fall through. 18521 // Fall through.
18498 case PropertyCellType::kConstantType: 18522 case PropertyCellType::kConstantType:
18499 if (RemainsConstantType(cell, value)) { 18523 if (RemainsConstantType(cell, value)) {
18500 return PropertyCellType::kConstantType; 18524 return PropertyCellType::kConstantType;
18501 } 18525 }
18502 // Fall through. 18526 // Fall through.
18503 case PropertyCellType::kMutable: 18527 case PropertyCellType::kMutable:
18504 return PropertyCellType::kMutable; 18528 return PropertyCellType::kMutable;
18505 } 18529 }
18506 UNREACHABLE(); 18530 UNREACHABLE();
18507 return PropertyCellType::kMutable; 18531 return PropertyCellType::kMutable;
18508 } 18532 }
18509 18533
18510 18534
18511 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, 18535 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry,
18512 Handle<Object> value, PropertyDetails details) { 18536 Handle<Object> value, PropertyDetails details) {
18513 DCHECK(!value->IsTheHole()); 18537 Isolate* isolate = dictionary->GetIsolate();
18538 DCHECK(!value->IsTheHole(isolate));
18514 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); 18539 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
18515 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); 18540 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
18516 const PropertyDetails original_details = cell->property_details(); 18541 const PropertyDetails original_details = cell->property_details();
18517 // Data accesses could be cached in ics or optimized code. 18542 // Data accesses could be cached in ics or optimized code.
18518 bool invalidate = 18543 bool invalidate =
18519 original_details.kind() == kData && details.kind() == kAccessor; 18544 original_details.kind() == kData && details.kind() == kAccessor;
18520 int index = original_details.dictionary_index(); 18545 int index = original_details.dictionary_index();
18521 PropertyCellType old_type = original_details.cell_type(); 18546 PropertyCellType old_type = original_details.cell_type();
18522 // Preserve the enumeration index unless the property was deleted or never 18547 // Preserve the enumeration index unless the property was deleted or never
18523 // initialized. 18548 // initialized.
18524 if (cell->value()->IsTheHole()) { 18549 if (cell->value()->IsTheHole(isolate)) {
18525 index = dictionary->NextEnumerationIndex(); 18550 index = dictionary->NextEnumerationIndex();
18526 dictionary->SetNextEnumerationIndex(index + 1); 18551 dictionary->SetNextEnumerationIndex(index + 1);
18527 // Negative lookup cells must be invalidated. 18552 // Negative lookup cells must be invalidated.
18528 invalidate = true; 18553 invalidate = true;
18529 } 18554 }
18530 DCHECK(index > 0); 18555 DCHECK(index > 0);
18531 details = details.set_index(index); 18556 details = details.set_index(index);
18532 18557
18533 PropertyCellType new_type = UpdatedType(cell, value, original_details); 18558 PropertyCellType new_type = UpdatedType(cell, value, original_details);
18534 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); 18559 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry);
18535 18560
18536 // Install new property details and cell value. 18561 // Install new property details and cell value.
18537 details = details.set_cell_type(new_type); 18562 details = details.set_cell_type(new_type);
18538 cell->set_property_details(details); 18563 cell->set_property_details(details);
18539 cell->set_value(*value); 18564 cell->set_value(*value);
18540 18565
18541 // Deopt when transitioning from a constant type. 18566 // Deopt when transitioning from a constant type.
18542 if (!invalidate && (old_type != new_type || 18567 if (!invalidate && (old_type != new_type ||
18543 original_details.IsReadOnly() != details.IsReadOnly())) { 18568 original_details.IsReadOnly() != details.IsReadOnly())) {
18544 Isolate* isolate = dictionary->GetIsolate();
18545 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18569 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18546 isolate, DependentCode::kPropertyCellChangedGroup); 18570 isolate, DependentCode::kPropertyCellChangedGroup);
18547 } 18571 }
18548 } 18572 }
18549 18573
18550 18574
18551 // static 18575 // static
18552 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, 18576 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell,
18553 Handle<Object> new_value) { 18577 Handle<Object> new_value) {
18554 if (cell->value() != *new_value) { 18578 if (cell->value() != *new_value) {
18555 cell->set_value(*new_value); 18579 cell->set_value(*new_value);
18556 Isolate* isolate = cell->GetIsolate(); 18580 Isolate* isolate = cell->GetIsolate();
18557 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18581 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18558 isolate, DependentCode::kPropertyCellChangedGroup); 18582 isolate, DependentCode::kPropertyCellChangedGroup);
18559 } 18583 }
18560 } 18584 }
18561 18585
18562 } // namespace internal 18586 } // namespace internal
18563 } // namespace v8 18587 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698