OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds. | 3303 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds. |
3298 // TODO(ishell): compare AccessorPairs. | 3304 // TODO(ishell): compare AccessorPairs. |
3299 return false; | 3305 return false; |
3300 } | 3306 } |
3301 | 3307 |
3302 | 3308 |
3303 // Installs |new_descriptors| over the current instance_descriptors to ensure | 3309 // Installs |new_descriptors| over the current instance_descriptors to ensure |
3304 // proper sharing of descriptor arrays. | 3310 // proper sharing of descriptor arrays. |
3305 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors, | 3311 void Map::ReplaceDescriptors(DescriptorArray* new_descriptors, |
3306 LayoutDescriptor* new_layout_descriptor) { | 3312 LayoutDescriptor* new_layout_descriptor) { |
| 3313 Isolate* isolate = GetIsolate(); |
3307 // Don't overwrite the empty descriptor array or initial map's descriptors. | 3314 // Don't overwrite the empty descriptor array or initial map's descriptors. |
3308 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined()) { | 3315 if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined(isolate)) { |
3309 return; | 3316 return; |
3310 } | 3317 } |
3311 | 3318 |
3312 DescriptorArray* to_replace = instance_descriptors(); | 3319 DescriptorArray* to_replace = instance_descriptors(); |
3313 GetHeap()->incremental_marking()->IterateBlackObject(to_replace); | 3320 isolate->heap()->incremental_marking()->IterateBlackObject(to_replace); |
3314 Map* current = this; | 3321 Map* current = this; |
3315 while (current->instance_descriptors() == to_replace) { | 3322 while (current->instance_descriptors() == to_replace) { |
3316 Object* next = current->GetBackPointer(); | 3323 Object* next = current->GetBackPointer(); |
3317 if (next->IsUndefined()) break; // Stop overwriting at initial map. | 3324 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map. |
3318 current->SetEnumLength(kInvalidEnumCacheSentinel); | 3325 current->SetEnumLength(kInvalidEnumCacheSentinel); |
3319 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); | 3326 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); |
3320 current = Map::cast(next); | 3327 current = Map::cast(next); |
3321 } | 3328 } |
3322 set_owns_descriptors(false); | 3329 set_owns_descriptors(false); |
3323 } | 3330 } |
3324 | 3331 |
3325 | 3332 |
3326 Map* Map::FindRootMap() { | 3333 Map* Map::FindRootMap() { |
3327 Map* result = this; | 3334 Map* result = this; |
| 3335 Isolate* isolate = GetIsolate(); |
3328 while (true) { | 3336 while (true) { |
3329 Object* back = result->GetBackPointer(); | 3337 Object* back = result->GetBackPointer(); |
3330 if (back->IsUndefined()) { | 3338 if (back->IsUndefined(isolate)) { |
3331 // Initial map always owns descriptors and doesn't have unused entries | 3339 // Initial map always owns descriptors and doesn't have unused entries |
3332 // in the descriptor array. | 3340 // in the descriptor array. |
3333 DCHECK(result->owns_descriptors()); | 3341 DCHECK(result->owns_descriptors()); |
3334 DCHECK_EQ(result->NumberOfOwnDescriptors(), | 3342 DCHECK_EQ(result->NumberOfOwnDescriptors(), |
3335 result->instance_descriptors()->number_of_descriptors()); | 3343 result->instance_descriptors()->number_of_descriptors()); |
3336 return result; | 3344 return result; |
3337 } | 3345 } |
3338 result = Map::cast(back); | 3346 result = Map::cast(back); |
3339 } | 3347 } |
3340 } | 3348 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 current = next; | 3386 current = next; |
3379 } | 3387 } |
3380 return current; | 3388 return current; |
3381 } | 3389 } |
3382 | 3390 |
3383 | 3391 |
3384 Map* Map::FindFieldOwner(int descriptor) { | 3392 Map* Map::FindFieldOwner(int descriptor) { |
3385 DisallowHeapAllocation no_allocation; | 3393 DisallowHeapAllocation no_allocation; |
3386 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type()); | 3394 DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type()); |
3387 Map* result = this; | 3395 Map* result = this; |
| 3396 Isolate* isolate = GetIsolate(); |
3388 while (true) { | 3397 while (true) { |
3389 Object* back = result->GetBackPointer(); | 3398 Object* back = result->GetBackPointer(); |
3390 if (back->IsUndefined()) break; | 3399 if (back->IsUndefined(isolate)) break; |
3391 Map* parent = Map::cast(back); | 3400 Map* parent = Map::cast(back); |
3392 if (parent->NumberOfOwnDescriptors() <= descriptor) break; | 3401 if (parent->NumberOfOwnDescriptors() <= descriptor) break; |
3393 result = parent; | 3402 result = parent; |
3394 } | 3403 } |
3395 return result; | 3404 return result; |
3396 } | 3405 } |
3397 | 3406 |
3398 | 3407 |
3399 void Map::UpdateFieldType(int descriptor, Handle<Name> name, | 3408 void Map::UpdateFieldType(int descriptor, Handle<Name> name, |
3400 Representation new_representation, | 3409 Representation new_representation, |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it, | 4206 Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it, |
4198 ShouldThrow should_throw, | 4207 ShouldThrow should_throw, |
4199 Handle<Object> value) { | 4208 Handle<Object> value) { |
4200 Isolate* isolate = it->isolate(); | 4209 Isolate* isolate = it->isolate(); |
4201 // Make sure that the top context does not change when doing callbacks or | 4210 // Make sure that the top context does not change when doing callbacks or |
4202 // interceptor calls. | 4211 // interceptor calls. |
4203 AssertNoContextChange ncc(isolate); | 4212 AssertNoContextChange ncc(isolate); |
4204 | 4213 |
4205 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); | 4214 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); |
4206 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); | 4215 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); |
4207 if (interceptor->setter()->IsUndefined()) return Just(false); | 4216 if (interceptor->setter()->IsUndefined(isolate)) return Just(false); |
4208 | 4217 |
4209 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 4218 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
4210 bool result; | 4219 bool result; |
4211 Handle<Object> receiver = it->GetReceiver(); | 4220 Handle<Object> receiver = it->GetReceiver(); |
4212 if (!receiver->IsJSReceiver()) { | 4221 if (!receiver->IsJSReceiver()) { |
4213 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, | 4222 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, |
4214 Object::ConvertReceiver(isolate, receiver), | 4223 Object::ConvertReceiver(isolate, receiver), |
4215 Nothing<bool>()); | 4224 Nothing<bool>()); |
4216 } | 4225 } |
4217 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, | 4226 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4508 // Proxies are handled elsewhere. Other non-JSObjects cannot have own | 4517 // Proxies are handled elsewhere. Other non-JSObjects cannot have own |
4509 // properties. | 4518 // properties. |
4510 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 4519 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); |
4511 | 4520 |
4512 // Store on the holder which may be hidden behind the receiver. | 4521 // Store on the holder which may be hidden behind the receiver. |
4513 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); | 4522 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); |
4514 | 4523 |
4515 Handle<Object> to_assign = value; | 4524 Handle<Object> to_assign = value; |
4516 // Convert the incoming value to a number for storing into typed arrays. | 4525 // Convert the incoming value to a number for storing into typed arrays. |
4517 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) { | 4526 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) { |
4518 if (!value->IsNumber() && !value->IsUndefined()) { | 4527 if (!value->IsNumber() && !value->IsUndefined(it->isolate())) { |
4519 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 4528 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
4520 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>()); | 4529 it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>()); |
4521 // We have to recheck the length. However, it can only change if the | 4530 // We have to recheck the length. However, it can only change if the |
4522 // underlying buffer was neutered, so just check that. | 4531 // underlying buffer was neutered, so just check that. |
4523 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { | 4532 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { |
4524 return Just(true); | 4533 return Just(true); |
4525 // TODO(neis): According to the spec, this should throw a TypeError. | 4534 // TODO(neis): According to the spec, this should throw a TypeError. |
4526 } | 4535 } |
4527 } | 4536 } |
4528 } | 4537 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4647 | 4656 |
4648 // If the source descriptors had an enum cache we copy it. This ensures | 4657 // If the source descriptors had an enum cache we copy it. This ensures |
4649 // that the maps to which we push the new descriptor array back can rely | 4658 // that the maps to which we push the new descriptor array back can rely |
4650 // on a cache always being available once it is set. If the map has more | 4659 // on a cache always being available once it is set. If the map has more |
4651 // enumerated descriptors than available in the original cache, the cache | 4660 // enumerated descriptors than available in the original cache, the cache |
4652 // will be lazily replaced by the extended cache when needed. | 4661 // will be lazily replaced by the extended cache when needed. |
4653 if (descriptors->HasEnumCache()) { | 4662 if (descriptors->HasEnumCache()) { |
4654 new_descriptors->CopyEnumCacheFrom(*descriptors); | 4663 new_descriptors->CopyEnumCacheFrom(*descriptors); |
4655 } | 4664 } |
4656 | 4665 |
| 4666 Isolate* isolate = map->GetIsolate(); |
4657 // Replace descriptors by new_descriptors in all maps that share it. | 4667 // Replace descriptors by new_descriptors in all maps that share it. |
4658 map->GetHeap()->incremental_marking()->IterateBlackObject(*descriptors); | 4668 isolate->heap()->incremental_marking()->IterateBlackObject(*descriptors); |
4659 | 4669 |
4660 Map* current = *map; | 4670 Map* current = *map; |
4661 while (current->instance_descriptors() == *descriptors) { | 4671 while (current->instance_descriptors() == *descriptors) { |
4662 Object* next = current->GetBackPointer(); | 4672 Object* next = current->GetBackPointer(); |
4663 if (next->IsUndefined()) break; // Stop overwriting at initial map. | 4673 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map. |
4664 current->UpdateDescriptors(*new_descriptors, layout_descriptor); | 4674 current->UpdateDescriptors(*new_descriptors, layout_descriptor); |
4665 current = Map::cast(next); | 4675 current = Map::cast(next); |
4666 } | 4676 } |
4667 map->UpdateDescriptors(*new_descriptors, layout_descriptor); | 4677 map->UpdateDescriptors(*new_descriptors, layout_descriptor); |
4668 } | 4678 } |
4669 | 4679 |
4670 | 4680 |
4671 template<class T> | 4681 template<class T> |
4672 static int AppendUniqueCallbacks(NeanderArray* callbacks, | 4682 static int AppendUniqueCallbacks(NeanderArray* callbacks, |
4673 Handle<typename T::Array> array, | 4683 Handle<typename T::Array> array, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4911 DisallowHeapAllocation no_gc; | 4921 DisallowHeapAllocation no_gc; |
4912 if (native_context->get(Context::ArrayMapIndex(from_kind)) == *map) { | 4922 if (native_context->get(Context::ArrayMapIndex(from_kind)) == *map) { |
4913 Object* maybe_transitioned_map = | 4923 Object* maybe_transitioned_map = |
4914 native_context->get(Context::ArrayMapIndex(to_kind)); | 4924 native_context->get(Context::ArrayMapIndex(to_kind)); |
4915 if (maybe_transitioned_map->IsMap()) { | 4925 if (maybe_transitioned_map->IsMap()) { |
4916 return handle(Map::cast(maybe_transitioned_map), isolate); | 4926 return handle(Map::cast(maybe_transitioned_map), isolate); |
4917 } | 4927 } |
4918 } | 4928 } |
4919 } | 4929 } |
4920 | 4930 |
4921 DCHECK(!map->IsUndefined()); | 4931 DCHECK(!map->IsUndefined(isolate)); |
4922 // Check if we can go back in the elements kind transition chain. | 4932 // Check if we can go back in the elements kind transition chain. |
4923 if (IsHoleyElementsKind(from_kind) && | 4933 if (IsHoleyElementsKind(from_kind) && |
4924 to_kind == GetPackedElementsKind(from_kind) && | 4934 to_kind == GetPackedElementsKind(from_kind) && |
4925 map->GetBackPointer()->IsMap() && | 4935 map->GetBackPointer()->IsMap() && |
4926 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { | 4936 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { |
4927 return handle(Map::cast(map->GetBackPointer())); | 4937 return handle(Map::cast(map->GetBackPointer())); |
4928 } | 4938 } |
4929 | 4939 |
4930 bool allow_store_transition = IsTransitionElementsKind(from_kind); | 4940 bool allow_store_transition = IsTransitionElementsKind(from_kind); |
4931 // Only store fast element maps in ascending generality. | 4941 // Only store fast element maps in ascending generality. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4985 } | 4995 } |
4986 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 4996 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
4987 Handle<JSReceiver> target(proxy->target(), isolate); | 4997 Handle<JSReceiver> target(proxy->target(), isolate); |
4988 // 6. Let trap be ? GetMethod(handler, "has"). | 4998 // 6. Let trap be ? GetMethod(handler, "has"). |
4989 Handle<Object> trap; | 4999 Handle<Object> trap; |
4990 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5000 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
4991 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), | 5001 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), |
4992 isolate->factory()->has_string()), | 5002 isolate->factory()->has_string()), |
4993 Nothing<bool>()); | 5003 Nothing<bool>()); |
4994 // 7. If trap is undefined, then | 5004 // 7. If trap is undefined, then |
4995 if (trap->IsUndefined()) { | 5005 if (trap->IsUndefined(isolate)) { |
4996 // 7a. Return target.[[HasProperty]](P). | 5006 // 7a. Return target.[[HasProperty]](P). |
4997 return JSReceiver::HasProperty(target, name); | 5007 return JSReceiver::HasProperty(target, name); |
4998 } | 5008 } |
4999 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)). | 5009 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)). |
5000 Handle<Object> trap_result_obj; | 5010 Handle<Object> trap_result_obj; |
5001 Handle<Object> args[] = {target, name}; | 5011 Handle<Object> args[] = {target, name}; |
5002 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5012 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
5003 isolate, trap_result_obj, | 5013 isolate, trap_result_obj, |
5004 Execution::Call(isolate, trap, handler, arraysize(args), args), | 5014 Execution::Call(isolate, trap, handler, arraysize(args), args), |
5005 Nothing<bool>()); | 5015 Nothing<bool>()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5051 isolate->Throw( | 5061 isolate->Throw( |
5052 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 5062 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
5053 return Nothing<bool>(); | 5063 return Nothing<bool>(); |
5054 } | 5064 } |
5055 Handle<JSReceiver> target(proxy->target(), isolate); | 5065 Handle<JSReceiver> target(proxy->target(), isolate); |
5056 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 5066 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
5057 | 5067 |
5058 Handle<Object> trap; | 5068 Handle<Object> trap; |
5059 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5069 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
5060 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); | 5070 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); |
5061 if (trap->IsUndefined()) { | 5071 if (trap->IsUndefined(isolate)) { |
5062 LookupIterator it = | 5072 LookupIterator it = |
5063 LookupIterator::PropertyOrElement(isolate, receiver, name, target); | 5073 LookupIterator::PropertyOrElement(isolate, receiver, name, target); |
5064 return Object::SetSuperProperty(&it, value, language_mode, | 5074 return Object::SetSuperProperty(&it, value, language_mode, |
5065 Object::MAY_BE_STORE_FROM_KEYED); | 5075 Object::MAY_BE_STORE_FROM_KEYED); |
5066 } | 5076 } |
5067 | 5077 |
5068 Handle<Object> trap_result; | 5078 Handle<Object> trap_result; |
5069 Handle<Object> args[] = {target, name, value, receiver}; | 5079 Handle<Object> args[] = {target, name, value, receiver}; |
5070 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5080 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
5071 isolate, trap_result, | 5081 isolate, trap_result, |
(...skipping 15 matching lines...) Expand all Loading... |
5087 !target_desc.configurable() && | 5097 !target_desc.configurable() && |
5088 !target_desc.writable() && | 5098 !target_desc.writable() && |
5089 !value->SameValue(*target_desc.value()); | 5099 !value->SameValue(*target_desc.value()); |
5090 if (inconsistent) { | 5100 if (inconsistent) { |
5091 isolate->Throw(*isolate->factory()->NewTypeError( | 5101 isolate->Throw(*isolate->factory()->NewTypeError( |
5092 MessageTemplate::kProxySetFrozenData, name)); | 5102 MessageTemplate::kProxySetFrozenData, name)); |
5093 return Nothing<bool>(); | 5103 return Nothing<bool>(); |
5094 } | 5104 } |
5095 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && | 5105 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && |
5096 !target_desc.configurable() && | 5106 !target_desc.configurable() && |
5097 target_desc.set()->IsUndefined(); | 5107 target_desc.set()->IsUndefined(isolate); |
5098 if (inconsistent) { | 5108 if (inconsistent) { |
5099 isolate->Throw(*isolate->factory()->NewTypeError( | 5109 isolate->Throw(*isolate->factory()->NewTypeError( |
5100 MessageTemplate::kProxySetFrozenAccessor, name)); | 5110 MessageTemplate::kProxySetFrozenAccessor, name)); |
5101 return Nothing<bool>(); | 5111 return Nothing<bool>(); |
5102 } | 5112 } |
5103 } | 5113 } |
5104 return Just(true); | 5114 return Just(true); |
5105 } | 5115 } |
5106 | 5116 |
5107 | 5117 |
(...skipping 12 matching lines...) Expand all Loading... |
5120 isolate->Throw( | 5130 isolate->Throw( |
5121 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 5131 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
5122 return Nothing<bool>(); | 5132 return Nothing<bool>(); |
5123 } | 5133 } |
5124 Handle<JSReceiver> target(proxy->target(), isolate); | 5134 Handle<JSReceiver> target(proxy->target(), isolate); |
5125 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 5135 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
5126 | 5136 |
5127 Handle<Object> trap; | 5137 Handle<Object> trap; |
5128 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5138 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
5129 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); | 5139 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); |
5130 if (trap->IsUndefined()) { | 5140 if (trap->IsUndefined(isolate)) { |
5131 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); | 5141 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); |
5132 } | 5142 } |
5133 | 5143 |
5134 Handle<Object> trap_result; | 5144 Handle<Object> trap_result; |
5135 Handle<Object> args[] = {target, name}; | 5145 Handle<Object> args[] = {target, name}; |
5136 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 5146 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
5137 isolate, trap_result, | 5147 isolate, trap_result, |
5138 Execution::Call(isolate, trap, handler, arraysize(args), args), | 5148 Execution::Call(isolate, trap, handler, arraysize(args), args), |
5139 Nothing<bool>()); | 5149 Nothing<bool>()); |
5140 if (!trap_result->BooleanValue()) { | 5150 if (!trap_result->BooleanValue()) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5469 } | 5479 } |
5470 } | 5480 } |
5471 | 5481 |
5472 return AddDataProperty(it, value, attributes, should_throw, | 5482 return AddDataProperty(it, value, attributes, should_throw, |
5473 CERTAINLY_NOT_STORE_FROM_KEYED); | 5483 CERTAINLY_NOT_STORE_FROM_KEYED); |
5474 } | 5484 } |
5475 | 5485 |
5476 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( | 5486 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( |
5477 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, | 5487 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, |
5478 PropertyAttributes attributes) { | 5488 PropertyAttributes attributes) { |
5479 DCHECK(!value->IsTheHole()); | 5489 DCHECK(!value->IsTheHole(object->GetIsolate())); |
5480 LookupIterator it(object, name, object, LookupIterator::OWN); | 5490 LookupIterator it(object, name, object, LookupIterator::OWN); |
5481 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); | 5491 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); |
5482 } | 5492 } |
5483 | 5493 |
5484 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( | 5494 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( |
5485 Handle<JSObject> object, uint32_t index, Handle<Object> value, | 5495 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
5486 PropertyAttributes attributes) { | 5496 PropertyAttributes attributes) { |
5487 Isolate* isolate = object->GetIsolate(); | 5497 Isolate* isolate = object->GetIsolate(); |
5488 LookupIterator it(isolate, object, index, object, LookupIterator::OWN); | 5498 LookupIterator it(isolate, object, index, object, LookupIterator::OWN); |
5489 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); | 5499 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); |
(...skipping 24 matching lines...) Expand all Loading... |
5514 return Just(ABSENT); | 5524 return Just(ABSENT); |
5515 } | 5525 } |
5516 Handle<Object> receiver = it->GetReceiver(); | 5526 Handle<Object> receiver = it->GetReceiver(); |
5517 if (!receiver->IsJSReceiver()) { | 5527 if (!receiver->IsJSReceiver()) { |
5518 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, | 5528 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, |
5519 Object::ConvertReceiver(isolate, receiver), | 5529 Object::ConvertReceiver(isolate, receiver), |
5520 Nothing<PropertyAttributes>()); | 5530 Nothing<PropertyAttributes>()); |
5521 } | 5531 } |
5522 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, | 5532 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, |
5523 *holder, Object::DONT_THROW); | 5533 *holder, Object::DONT_THROW); |
5524 if (!interceptor->query()->IsUndefined()) { | 5534 if (!interceptor->query()->IsUndefined(isolate)) { |
5525 Handle<Object> result; | 5535 Handle<Object> result; |
5526 if (it->IsElement()) { | 5536 if (it->IsElement()) { |
5527 uint32_t index = it->index(); | 5537 uint32_t index = it->index(); |
5528 v8::IndexedPropertyQueryCallback query = | 5538 v8::IndexedPropertyQueryCallback query = |
5529 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); | 5539 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); |
5530 result = args.Call(query, index); | 5540 result = args.Call(query, index); |
5531 } else { | 5541 } else { |
5532 Handle<Name> name = it->name(); | 5542 Handle<Name> name = it->name(); |
5533 DCHECK(!name->IsPrivate()); | 5543 DCHECK(!name->IsPrivate()); |
5534 v8::GenericNamedPropertyQueryCallback query = | 5544 v8::GenericNamedPropertyQueryCallback query = |
5535 v8::ToCData<v8::GenericNamedPropertyQueryCallback>( | 5545 v8::ToCData<v8::GenericNamedPropertyQueryCallback>( |
5536 interceptor->query()); | 5546 interceptor->query()); |
5537 result = args.Call(query, name); | 5547 result = args.Call(query, name); |
5538 } | 5548 } |
5539 if (!result.is_null()) { | 5549 if (!result.is_null()) { |
5540 int32_t value; | 5550 int32_t value; |
5541 CHECK(result->ToInt32(&value)); | 5551 CHECK(result->ToInt32(&value)); |
5542 return Just(static_cast<PropertyAttributes>(value)); | 5552 return Just(static_cast<PropertyAttributes>(value)); |
5543 } | 5553 } |
5544 } else if (!interceptor->getter()->IsUndefined()) { | 5554 } else if (!interceptor->getter()->IsUndefined(isolate)) { |
5545 // TODO(verwaest): Use GetPropertyWithInterceptor? | 5555 // TODO(verwaest): Use GetPropertyWithInterceptor? |
5546 Handle<Object> result; | 5556 Handle<Object> result; |
5547 if (it->IsElement()) { | 5557 if (it->IsElement()) { |
5548 uint32_t index = it->index(); | 5558 uint32_t index = it->index(); |
5549 v8::IndexedPropertyGetterCallback getter = | 5559 v8::IndexedPropertyGetterCallback getter = |
5550 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); | 5560 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
5551 result = args.Call(getter, index); | 5561 result = args.Call(getter, index); |
5552 } else { | 5562 } else { |
5553 Handle<Name> name = it->name(); | 5563 Handle<Name> name = it->name(); |
5554 DCHECK(!name->IsPrivate()); | 5564 DCHECK(!name->IsPrivate()); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5954 | 5964 |
5955 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it, | 5965 Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it, |
5956 ShouldThrow should_throw) { | 5966 ShouldThrow should_throw) { |
5957 Isolate* isolate = it->isolate(); | 5967 Isolate* isolate = it->isolate(); |
5958 // Make sure that the top context does not change when doing callbacks or | 5968 // Make sure that the top context does not change when doing callbacks or |
5959 // interceptor calls. | 5969 // interceptor calls. |
5960 AssertNoContextChange ncc(isolate); | 5970 AssertNoContextChange ncc(isolate); |
5961 | 5971 |
5962 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); | 5972 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); |
5963 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); | 5973 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); |
5964 if (interceptor->deleter()->IsUndefined()) return Nothing<bool>(); | 5974 if (interceptor->deleter()->IsUndefined(isolate)) return Nothing<bool>(); |
5965 | 5975 |
5966 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 5976 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
5967 Handle<Object> receiver = it->GetReceiver(); | 5977 Handle<Object> receiver = it->GetReceiver(); |
5968 if (!receiver->IsJSReceiver()) { | 5978 if (!receiver->IsJSReceiver()) { |
5969 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, | 5979 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver, |
5970 Object::ConvertReceiver(isolate, receiver), | 5980 Object::ConvertReceiver(isolate, receiver), |
5971 Nothing<bool>()); | 5981 Nothing<bool>()); |
5972 } | 5982 } |
5973 | 5983 |
5974 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, | 5984 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6891 } | 6901 } |
6892 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 6902 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
6893 Handle<JSReceiver> target(proxy->target(), isolate); | 6903 Handle<JSReceiver> target(proxy->target(), isolate); |
6894 // 6. Let trap be ? GetMethod(handler, "defineProperty"). | 6904 // 6. Let trap be ? GetMethod(handler, "defineProperty"). |
6895 Handle<Object> trap; | 6905 Handle<Object> trap; |
6896 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 6906 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
6897 isolate, trap, | 6907 isolate, trap, |
6898 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), | 6908 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), |
6899 Nothing<bool>()); | 6909 Nothing<bool>()); |
6900 // 7. If trap is undefined, then: | 6910 // 7. If trap is undefined, then: |
6901 if (trap->IsUndefined()) { | 6911 if (trap->IsUndefined(isolate)) { |
6902 // 7a. Return target.[[DefineOwnProperty]](P, Desc). | 6912 // 7a. Return target.[[DefineOwnProperty]](P, Desc). |
6903 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, | 6913 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, |
6904 should_throw); | 6914 should_throw); |
6905 } | 6915 } |
6906 // 8. Let descObj be FromPropertyDescriptor(Desc). | 6916 // 8. Let descObj be FromPropertyDescriptor(Desc). |
6907 Handle<Object> desc_obj = desc->ToObject(isolate); | 6917 Handle<Object> desc_obj = desc->ToObject(isolate); |
6908 // 9. Let booleanTrapResult be | 6918 // 9. Let booleanTrapResult be |
6909 // ToBoolean(? Call(trap, handler, «target, P, descObj»)). | 6919 // ToBoolean(? Call(trap, handler, «target, P, descObj»)). |
6910 Handle<Name> property_name = | 6920 Handle<Name> property_name = |
6911 key->IsName() | 6921 key->IsName() |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7109 } | 7119 } |
7110 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 7120 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
7111 Handle<JSReceiver> target(proxy->target(), isolate); | 7121 Handle<JSReceiver> target(proxy->target(), isolate); |
7112 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). | 7122 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). |
7113 Handle<Object> trap; | 7123 Handle<Object> trap; |
7114 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7124 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7115 isolate, trap, | 7125 isolate, trap, |
7116 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), | 7126 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), |
7117 Nothing<bool>()); | 7127 Nothing<bool>()); |
7118 // 7. If trap is undefined, then | 7128 // 7. If trap is undefined, then |
7119 if (trap->IsUndefined()) { | 7129 if (trap->IsUndefined(isolate)) { |
7120 // 7a. Return target.[[GetOwnProperty]](P). | 7130 // 7a. Return target.[[GetOwnProperty]](P). |
7121 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); | 7131 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); |
7122 } | 7132 } |
7123 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»). | 7133 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»). |
7124 Handle<Object> trap_result_obj; | 7134 Handle<Object> trap_result_obj; |
7125 Handle<Object> args[] = {target, name}; | 7135 Handle<Object> args[] = {target, name}; |
7126 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7136 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7127 isolate, trap_result_obj, | 7137 isolate, trap_result_obj, |
7128 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7138 Execution::Call(isolate, trap, handler, arraysize(args), args), |
7129 Nothing<bool>()); | 7139 Nothing<bool>()); |
7130 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a | 7140 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a |
7131 // TypeError exception. | 7141 // TypeError exception. |
7132 if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) { | 7142 if (!trap_result_obj->IsJSReceiver() && |
| 7143 !trap_result_obj->IsUndefined(isolate)) { |
7133 isolate->Throw(*isolate->factory()->NewTypeError( | 7144 isolate->Throw(*isolate->factory()->NewTypeError( |
7134 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name)); | 7145 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name)); |
7135 return Nothing<bool>(); | 7146 return Nothing<bool>(); |
7136 } | 7147 } |
7137 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). | 7148 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). |
7138 PropertyDescriptor target_desc; | 7149 PropertyDescriptor target_desc; |
7139 Maybe<bool> found = | 7150 Maybe<bool> found = |
7140 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); | 7151 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); |
7141 MAYBE_RETURN(found, Nothing<bool>()); | 7152 MAYBE_RETURN(found, Nothing<bool>()); |
7142 // 11. If trapResultObj is undefined, then | 7153 // 11. If trapResultObj is undefined, then |
7143 if (trap_result_obj->IsUndefined()) { | 7154 if (trap_result_obj->IsUndefined(isolate)) { |
7144 // 11a. If targetDesc is undefined, return undefined. | 7155 // 11a. If targetDesc is undefined, return undefined. |
7145 if (!found.FromJust()) return Just(false); | 7156 if (!found.FromJust()) return Just(false); |
7146 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError | 7157 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError |
7147 // exception. | 7158 // exception. |
7148 if (!target_desc.configurable()) { | 7159 if (!target_desc.configurable()) { |
7149 isolate->Throw(*isolate->factory()->NewTypeError( | 7160 isolate->Throw(*isolate->factory()->NewTypeError( |
7150 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name)); | 7161 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name)); |
7151 return Nothing<bool>(); | 7162 return Nothing<bool>(); |
7152 } | 7163 } |
7153 // 11c. Let extensibleTarget be ? IsExtensible(target). | 7164 // 11c. Let extensibleTarget be ? IsExtensible(target). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7198 } | 7209 } |
7199 } | 7210 } |
7200 // 18. Return resultDesc. | 7211 // 18. Return resultDesc. |
7201 return Just(true); | 7212 return Just(true); |
7202 } | 7213 } |
7203 | 7214 |
7204 | 7215 |
7205 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, | 7216 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, |
7206 ElementsKind kind, | 7217 ElementsKind kind, |
7207 Object* object) { | 7218 Object* object) { |
| 7219 Isolate* isolate = elements->GetIsolate(); |
7208 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) { | 7220 if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) { |
7209 int length = IsJSArray() | 7221 int length = IsJSArray() |
7210 ? Smi::cast(JSArray::cast(this)->length())->value() | 7222 ? Smi::cast(JSArray::cast(this)->length())->value() |
7211 : elements->length(); | 7223 : elements->length(); |
7212 for (int i = 0; i < length; ++i) { | 7224 for (int i = 0; i < length; ++i) { |
7213 Object* element = elements->get(i); | 7225 Object* element = elements->get(i); |
7214 if (!element->IsTheHole() && element == object) return true; | 7226 if (!element->IsTheHole(isolate) && element == object) return true; |
7215 } | 7227 } |
7216 } else { | 7228 } else { |
7217 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS); | 7229 DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS); |
7218 Object* key = | 7230 Object* key = |
7219 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object); | 7231 SeededNumberDictionary::cast(elements)->SlowReverseLookup(object); |
7220 if (!key->IsUndefined()) return true; | 7232 if (!key->IsUndefined(isolate)) return true; |
7221 } | 7233 } |
7222 return false; | 7234 return false; |
7223 } | 7235 } |
7224 | 7236 |
7225 | 7237 |
7226 // Check whether this object references another object. | 7238 // Check whether this object references another object. |
7227 bool JSObject::ReferencesObject(Object* obj) { | 7239 bool JSObject::ReferencesObject(Object* obj) { |
7228 Map* map_of_this = map(); | 7240 Map* map_of_this = map(); |
7229 Heap* heap = GetHeap(); | 7241 Heap* heap = GetHeap(); |
7230 DisallowHeapAllocation no_allocation; | 7242 DisallowHeapAllocation no_allocation; |
7231 | 7243 |
7232 // Is the object the constructor for this object? | 7244 // Is the object the constructor for this object? |
7233 if (map_of_this->GetConstructor() == obj) { | 7245 if (map_of_this->GetConstructor() == obj) { |
7234 return true; | 7246 return true; |
7235 } | 7247 } |
7236 | 7248 |
7237 // Is the object the prototype for this object? | 7249 // Is the object the prototype for this object? |
7238 if (map_of_this->prototype() == obj) { | 7250 if (map_of_this->prototype() == obj) { |
7239 return true; | 7251 return true; |
7240 } | 7252 } |
7241 | 7253 |
7242 // Check if the object is among the named properties. | 7254 // Check if the object is among the named properties. |
7243 Object* key = SlowReverseLookup(obj); | 7255 Object* key = SlowReverseLookup(obj); |
7244 if (!key->IsUndefined()) { | 7256 if (!key->IsUndefined(heap->isolate())) { |
7245 return true; | 7257 return true; |
7246 } | 7258 } |
7247 | 7259 |
7248 // Check if the object is among the indexed properties. | 7260 // Check if the object is among the indexed properties. |
7249 ElementsKind kind = GetElementsKind(); | 7261 ElementsKind kind = GetElementsKind(); |
7250 switch (kind) { | 7262 switch (kind) { |
7251 // Raw pixels and external arrays do not reference other | 7263 // Raw pixels and external arrays do not reference other |
7252 // objects. | 7264 // objects. |
7253 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 7265 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
7254 case TYPE##_ELEMENTS: \ | 7266 case TYPE##_ELEMENTS: \ |
(...skipping 17 matching lines...) Expand all Loading... |
7272 if (ReferencesObjectFromElements(elements, kind, obj)) return true; | 7284 if (ReferencesObjectFromElements(elements, kind, obj)) return true; |
7273 break; | 7285 break; |
7274 } | 7286 } |
7275 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 7287 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
7276 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { | 7288 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { |
7277 FixedArray* parameter_map = FixedArray::cast(elements()); | 7289 FixedArray* parameter_map = FixedArray::cast(elements()); |
7278 // Check the mapped parameters. | 7290 // Check the mapped parameters. |
7279 int length = parameter_map->length(); | 7291 int length = parameter_map->length(); |
7280 for (int i = 2; i < length; ++i) { | 7292 for (int i = 2; i < length; ++i) { |
7281 Object* value = parameter_map->get(i); | 7293 Object* value = parameter_map->get(i); |
7282 if (!value->IsTheHole() && value == obj) return true; | 7294 if (!value->IsTheHole(heap->isolate()) && value == obj) return true; |
7283 } | 7295 } |
7284 // Check the arguments. | 7296 // Check the arguments. |
7285 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 7297 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
7286 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : | 7298 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : |
7287 FAST_HOLEY_ELEMENTS; | 7299 FAST_HOLEY_ELEMENTS; |
7288 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; | 7300 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; |
7289 break; | 7301 break; |
7290 } | 7302 } |
7291 case NO_ELEMENTS: | 7303 case NO_ELEMENTS: |
7292 break; | 7304 break; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7459 isolate->Throw( | 7471 isolate->Throw( |
7460 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 7472 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
7461 return Nothing<bool>(); | 7473 return Nothing<bool>(); |
7462 } | 7474 } |
7463 Handle<JSReceiver> target(proxy->target(), isolate); | 7475 Handle<JSReceiver> target(proxy->target(), isolate); |
7464 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 7476 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
7465 | 7477 |
7466 Handle<Object> trap; | 7478 Handle<Object> trap; |
7467 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7479 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7468 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); | 7480 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); |
7469 if (trap->IsUndefined()) { | 7481 if (trap->IsUndefined(isolate)) { |
7470 return JSReceiver::PreventExtensions(target, should_throw); | 7482 return JSReceiver::PreventExtensions(target, should_throw); |
7471 } | 7483 } |
7472 | 7484 |
7473 Handle<Object> trap_result; | 7485 Handle<Object> trap_result; |
7474 Handle<Object> args[] = {target}; | 7486 Handle<Object> args[] = {target}; |
7475 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7487 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7476 isolate, trap_result, | 7488 isolate, trap_result, |
7477 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7489 Execution::Call(isolate, trap, handler, arraysize(args), args), |
7478 Nothing<bool>()); | 7490 Nothing<bool>()); |
7479 if (!trap_result->BooleanValue()) { | 7491 if (!trap_result->BooleanValue()) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7561 isolate->Throw( | 7573 isolate->Throw( |
7562 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 7574 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
7563 return Nothing<bool>(); | 7575 return Nothing<bool>(); |
7564 } | 7576 } |
7565 Handle<JSReceiver> target(proxy->target(), isolate); | 7577 Handle<JSReceiver> target(proxy->target(), isolate); |
7566 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 7578 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
7567 | 7579 |
7568 Handle<Object> trap; | 7580 Handle<Object> trap; |
7569 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7581 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7570 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); | 7582 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); |
7571 if (trap->IsUndefined()) { | 7583 if (trap->IsUndefined(isolate)) { |
7572 return JSReceiver::IsExtensible(target); | 7584 return JSReceiver::IsExtensible(target); |
7573 } | 7585 } |
7574 | 7586 |
7575 Handle<Object> trap_result; | 7587 Handle<Object> trap_result; |
7576 Handle<Object> args[] = {target}; | 7588 Handle<Object> args[] = {target}; |
7577 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7589 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
7578 isolate, trap_result, | 7590 isolate, trap_result, |
7579 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7591 Execution::Call(isolate, trap, handler, arraysize(args), args), |
7580 Nothing<bool>()); | 7592 Nothing<bool>()); |
7581 | 7593 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8013 } | 8025 } |
8014 | 8026 |
8015 // static | 8027 // static |
8016 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver, | 8028 MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver, |
8017 ToPrimitiveHint hint) { | 8029 ToPrimitiveHint hint) { |
8018 Isolate* const isolate = receiver->GetIsolate(); | 8030 Isolate* const isolate = receiver->GetIsolate(); |
8019 Handle<Object> exotic_to_prim; | 8031 Handle<Object> exotic_to_prim; |
8020 ASSIGN_RETURN_ON_EXCEPTION( | 8032 ASSIGN_RETURN_ON_EXCEPTION( |
8021 isolate, exotic_to_prim, | 8033 isolate, exotic_to_prim, |
8022 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object); | 8034 GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object); |
8023 if (!exotic_to_prim->IsUndefined()) { | 8035 if (!exotic_to_prim->IsUndefined(isolate)) { |
8024 Handle<Object> hint_string; | 8036 Handle<Object> hint_string; |
8025 switch (hint) { | 8037 switch (hint) { |
8026 case ToPrimitiveHint::kDefault: | 8038 case ToPrimitiveHint::kDefault: |
8027 hint_string = isolate->factory()->default_string(); | 8039 hint_string = isolate->factory()->default_string(); |
8028 break; | 8040 break; |
8029 case ToPrimitiveHint::kNumber: | 8041 case ToPrimitiveHint::kNumber: |
8030 hint_string = isolate->factory()->number_string(); | 8042 hint_string = isolate->factory()->number_string(); |
8031 break; | 8043 break; |
8032 case ToPrimitiveHint::kString: | 8044 case ToPrimitiveHint::kString: |
8033 hint_string = isolate->factory()->string_string(); | 8045 hint_string = isolate->factory()->string_string(); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8391 } | 8403 } |
8392 it->Next(); | 8404 it->Next(); |
8393 } | 8405 } |
8394 | 8406 |
8395 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); | 8407 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); |
8396 // Ignore accessors on typed arrays. | 8408 // Ignore accessors on typed arrays. |
8397 if (it->IsElement() && object->HasFixedTypedArrayElements()) { | 8409 if (it->IsElement() && object->HasFixedTypedArrayElements()) { |
8398 return it->factory()->undefined_value(); | 8410 return it->factory()->undefined_value(); |
8399 } | 8411 } |
8400 | 8412 |
8401 DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull() || | 8413 DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) || |
8402 getter->IsFunctionTemplateInfo()); | 8414 getter->IsNull() || getter->IsFunctionTemplateInfo()); |
8403 DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() || | 8415 DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) || |
8404 getter->IsFunctionTemplateInfo()); | 8416 setter->IsNull() || getter->IsFunctionTemplateInfo()); |
8405 it->TransitionToAccessorProperty(getter, setter, attributes); | 8417 it->TransitionToAccessorProperty(getter, setter, attributes); |
8406 | 8418 |
8407 return isolate->factory()->undefined_value(); | 8419 return isolate->factory()->undefined_value(); |
8408 } | 8420 } |
8409 | 8421 |
8410 | 8422 |
8411 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, | 8423 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, |
8412 Handle<AccessorInfo> info) { | 8424 Handle<AccessorInfo> info) { |
8413 Isolate* isolate = object->GetIsolate(); | 8425 Isolate* isolate = object->GetIsolate(); |
8414 Handle<Name> name(Name::cast(info->name()), isolate); | 8426 Handle<Name> name(Name::cast(info->name()), isolate); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8512 } | 8524 } |
8513 | 8525 |
8514 | 8526 |
8515 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, | 8527 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, |
8516 const char* reason) { | 8528 const char* reason) { |
8517 DCHECK(!fast_map->is_dictionary_map()); | 8529 DCHECK(!fast_map->is_dictionary_map()); |
8518 | 8530 |
8519 Isolate* isolate = fast_map->GetIsolate(); | 8531 Isolate* isolate = fast_map->GetIsolate(); |
8520 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(), | 8532 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(), |
8521 isolate); | 8533 isolate); |
8522 bool use_cache = !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(); | 8534 bool use_cache = |
| 8535 !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(isolate); |
8523 Handle<NormalizedMapCache> cache; | 8536 Handle<NormalizedMapCache> cache; |
8524 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache); | 8537 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache); |
8525 | 8538 |
8526 Handle<Map> new_map; | 8539 Handle<Map> new_map; |
8527 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) { | 8540 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) { |
8528 #ifdef VERIFY_HEAP | 8541 #ifdef VERIFY_HEAP |
8529 if (FLAG_verify_heap) new_map->DictionaryMapVerify(); | 8542 if (FLAG_verify_heap) new_map->DictionaryMapVerify(); |
8530 #endif | 8543 #endif |
8531 #ifdef ENABLE_SLOW_DCHECKS | 8544 #ifdef ENABLE_SLOW_DCHECKS |
8532 if (FLAG_enable_slow_asserts) { | 8545 if (FLAG_enable_slow_asserts) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8723 Map::TraceTransition("Transition", map, target, key); | 8736 Map::TraceTransition("Transition", map, target, key); |
8724 Map::TraceAllTransitions(target); | 8737 Map::TraceAllTransitions(target); |
8725 } | 8738 } |
8726 } | 8739 } |
8727 | 8740 |
8728 #endif // TRACE_MAPS | 8741 #endif // TRACE_MAPS |
8729 | 8742 |
8730 | 8743 |
8731 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, | 8744 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, |
8732 Handle<Name> name, SimpleTransitionFlag flag) { | 8745 Handle<Name> name, SimpleTransitionFlag flag) { |
8733 if (!parent->GetBackPointer()->IsUndefined()) { | 8746 if (!parent->GetBackPointer()->IsUndefined(parent->GetIsolate())) { |
8734 parent->set_owns_descriptors(false); | 8747 parent->set_owns_descriptors(false); |
8735 } else { | 8748 } else { |
8736 // |parent| is initial map and it must keep the ownership, there must be no | 8749 // |parent| is initial map and it must keep the ownership, there must be no |
8737 // descriptors in the descriptors array that do not belong to the map. | 8750 // descriptors in the descriptors array that do not belong to the map. |
8738 DCHECK(parent->owns_descriptors()); | 8751 DCHECK(parent->owns_descriptors()); |
8739 DCHECK_EQ(parent->NumberOfOwnDescriptors(), | 8752 DCHECK_EQ(parent->NumberOfOwnDescriptors(), |
8740 parent->instance_descriptors()->number_of_descriptors()); | 8753 parent->instance_descriptors()->number_of_descriptors()); |
8741 } | 8754 } |
8742 if (parent->is_prototype_map()) { | 8755 if (parent->is_prototype_map()) { |
8743 DCHECK(child->is_prototype_map()); | 8756 DCHECK(child->is_prototype_map()); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9310 } | 9323 } |
9311 | 9324 |
9312 | 9325 |
9313 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map, | 9326 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map, |
9314 Descriptor* descriptor, | 9327 Descriptor* descriptor, |
9315 TransitionFlag flag) { | 9328 TransitionFlag flag) { |
9316 Handle<DescriptorArray> descriptors(map->instance_descriptors()); | 9329 Handle<DescriptorArray> descriptors(map->instance_descriptors()); |
9317 | 9330 |
9318 // Share descriptors only if map owns descriptors and it not an initial map. | 9331 // Share descriptors only if map owns descriptors and it not an initial map. |
9319 if (flag == INSERT_TRANSITION && map->owns_descriptors() && | 9332 if (flag == INSERT_TRANSITION && map->owns_descriptors() && |
9320 !map->GetBackPointer()->IsUndefined() && | 9333 !map->GetBackPointer()->IsUndefined(map->GetIsolate()) && |
9321 TransitionArray::CanHaveMoreTransitions(map)) { | 9334 TransitionArray::CanHaveMoreTransitions(map)) { |
9322 return ShareDescriptor(map, descriptors, descriptor); | 9335 return ShareDescriptor(map, descriptors, descriptor); |
9323 } | 9336 } |
9324 | 9337 |
9325 int nof = map->NumberOfOwnDescriptors(); | 9338 int nof = map->NumberOfOwnDescriptors(); |
9326 Handle<DescriptorArray> new_descriptors = | 9339 Handle<DescriptorArray> new_descriptors = |
9327 DescriptorArray::CopyUpTo(descriptors, nof, 1); | 9340 DescriptorArray::CopyUpTo(descriptors, nof, 1); |
9328 new_descriptors->Append(descriptor); | 9341 new_descriptors->Append(descriptor); |
9329 | 9342 |
9330 Handle<LayoutDescriptor> new_layout_descriptor = | 9343 Handle<LayoutDescriptor> new_layout_descriptor = |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10206 return true; | 10219 return true; |
10207 } | 10220 } |
10208 | 10221 |
10209 | 10222 |
10210 // static | 10223 // static |
10211 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) { | 10224 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) { |
10212 if (name->IsString()) return Handle<String>::cast(name); | 10225 if (name->IsString()) return Handle<String>::cast(name); |
10213 // ES6 section 9.2.11 SetFunctionName, step 4. | 10226 // ES6 section 9.2.11 SetFunctionName, step 4. |
10214 Isolate* const isolate = name->GetIsolate(); | 10227 Isolate* const isolate = name->GetIsolate(); |
10215 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate); | 10228 Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate); |
10216 if (description->IsUndefined()) return isolate->factory()->empty_string(); | 10229 if (description->IsUndefined(isolate)) { |
| 10230 return isolate->factory()->empty_string(); |
| 10231 } |
10217 IncrementalStringBuilder builder(isolate); | 10232 IncrementalStringBuilder builder(isolate); |
10218 builder.AppendCharacter('['); | 10233 builder.AppendCharacter('['); |
10219 builder.AppendString(Handle<String>::cast(description)); | 10234 builder.AppendString(Handle<String>::cast(description)); |
10220 builder.AppendCharacter(']'); | 10235 builder.AppendCharacter(']'); |
10221 return builder.Finish(); | 10236 return builder.Finish(); |
10222 } | 10237 } |
10223 | 10238 |
10224 | 10239 |
10225 namespace { | 10240 namespace { |
10226 | 10241 |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11763 // Visitor id might depend on the instance size, recalculate it. | 11778 // Visitor id might depend on the instance size, recalculate it. |
11764 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); | 11779 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); |
11765 } | 11780 } |
11766 | 11781 |
11767 static void StopSlackTracking(Map* map, void* data) { | 11782 static void StopSlackTracking(Map* map, void* data) { |
11768 map->set_construction_counter(Map::kNoSlackTracking); | 11783 map->set_construction_counter(Map::kNoSlackTracking); |
11769 } | 11784 } |
11770 | 11785 |
11771 void Map::CompleteInobjectSlackTracking() { | 11786 void Map::CompleteInobjectSlackTracking() { |
11772 // Has to be an initial map. | 11787 // Has to be an initial map. |
11773 DCHECK(GetBackPointer()->IsUndefined()); | 11788 DCHECK(GetBackPointer()->IsUndefined(GetIsolate())); |
11774 | 11789 |
11775 int slack = unused_property_fields(); | 11790 int slack = unused_property_fields(); |
11776 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack); | 11791 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack); |
11777 if (slack != 0) { | 11792 if (slack != 0) { |
11778 // Resize the initial map and all maps in its transition tree. | 11793 // Resize the initial map and all maps in its transition tree. |
11779 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); | 11794 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); |
11780 } else { | 11795 } else { |
11781 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr); | 11796 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr); |
11782 } | 11797 } |
11783 } | 11798 } |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12575 } | 12590 } |
12576 | 12591 |
12577 int Script::GetEvalPosition() { | 12592 int Script::GetEvalPosition() { |
12578 DisallowHeapAllocation no_gc; | 12593 DisallowHeapAllocation no_gc; |
12579 DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL); | 12594 DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL); |
12580 int position = eval_from_position(); | 12595 int position = eval_from_position(); |
12581 if (position < 0) { | 12596 if (position < 0) { |
12582 // Due to laziness, the position may not have been translated from code | 12597 // Due to laziness, the position may not have been translated from code |
12583 // offset yet, which would be encoded as negative integer. In that case, | 12598 // offset yet, which would be encoded as negative integer. In that case, |
12584 // translate and set the position. | 12599 // translate and set the position. |
12585 if (eval_from_shared()->IsUndefined()) { | 12600 if (eval_from_shared()->IsUndefined(GetIsolate())) { |
12586 position = 0; | 12601 position = 0; |
12587 } else { | 12602 } else { |
12588 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared()); | 12603 SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared()); |
12589 position = shared->abstract_code()->SourcePosition(-position); | 12604 position = shared->abstract_code()->SourcePosition(-position); |
12590 } | 12605 } |
12591 DCHECK(position >= 0); | 12606 DCHECK(position >= 0); |
12592 set_eval_from_position(position); | 12607 set_eval_from_position(position); |
12593 } | 12608 } |
12594 return position; | 12609 return position; |
12595 } | 12610 } |
12596 | 12611 |
12597 void Script::InitLineEnds(Handle<Script> script) { | 12612 void Script::InitLineEnds(Handle<Script> script) { |
12598 if (!script->line_ends()->IsUndefined()) return; | |
12599 | |
12600 Isolate* isolate = script->GetIsolate(); | 12613 Isolate* isolate = script->GetIsolate(); |
| 12614 if (!script->line_ends()->IsUndefined(isolate)) return; |
12601 | 12615 |
12602 if (!script->source()->IsString()) { | 12616 if (!script->source()->IsString()) { |
12603 DCHECK(script->source()->IsUndefined()); | 12617 DCHECK(script->source()->IsUndefined(isolate)); |
12604 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0); | 12618 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0); |
12605 script->set_line_ends(*empty); | 12619 script->set_line_ends(*empty); |
12606 DCHECK(script->line_ends()->IsFixedArray()); | 12620 DCHECK(script->line_ends()->IsFixedArray()); |
12607 return; | 12621 return; |
12608 } | 12622 } |
12609 | 12623 |
12610 Handle<String> src(String::cast(script->source()), isolate); | 12624 Handle<String> src(String::cast(script->source()), isolate); |
12611 | 12625 |
12612 Handle<FixedArray> array = String::CalculateLineEnds(src, true); | 12626 Handle<FixedArray> array = String::CalculateLineEnds(src, true); |
12613 | 12627 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12710 | 12724 |
12711 | 12725 |
12712 int Script::GetLineNumber(Handle<Script> script, int code_pos) { | 12726 int Script::GetLineNumber(Handle<Script> script, int code_pos) { |
12713 InitLineEnds(script); | 12727 InitLineEnds(script); |
12714 return script->GetLineNumberWithArray(code_pos); | 12728 return script->GetLineNumberWithArray(code_pos); |
12715 } | 12729 } |
12716 | 12730 |
12717 | 12731 |
12718 int Script::GetLineNumber(int code_pos) { | 12732 int Script::GetLineNumber(int code_pos) { |
12719 DisallowHeapAllocation no_allocation; | 12733 DisallowHeapAllocation no_allocation; |
12720 if (!line_ends()->IsUndefined()) return GetLineNumberWithArray(code_pos); | 12734 if (!line_ends()->IsUndefined(GetIsolate())) { |
| 12735 return GetLineNumberWithArray(code_pos); |
| 12736 } |
12721 | 12737 |
12722 // Slow mode: we do not have line_ends. We have to iterate through source. | 12738 // Slow mode: we do not have line_ends. We have to iterate through source. |
12723 if (!source()->IsString()) return -1; | 12739 if (!source()->IsString()) return -1; |
12724 | 12740 |
12725 String* source_string = String::cast(source()); | 12741 String* source_string = String::cast(source()); |
12726 int line = 0; | 12742 int line = 0; |
12727 int len = source_string->length(); | 12743 int len = source_string->length(); |
12728 for (int pos = 0; pos < len; pos++) { | 12744 for (int pos = 0; pos < len; pos++) { |
12729 if (pos == code_pos) break; | 12745 if (pos == code_pos) break; |
12730 if (source_string->Get(pos) == '\n') line++; | 12746 if (source_string->Get(pos) == '\n') line++; |
(...skipping 18 matching lines...) Expand all Loading... |
12749 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL) | 12765 if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL) |
12750 .ToHandle(&result)) { | 12766 .ToHandle(&result)) { |
12751 return isolate->factory()->undefined_value(); | 12767 return isolate->factory()->undefined_value(); |
12752 } | 12768 } |
12753 return result; | 12769 return result; |
12754 } | 12770 } |
12755 | 12771 |
12756 | 12772 |
12757 Handle<JSObject> Script::GetWrapper(Handle<Script> script) { | 12773 Handle<JSObject> Script::GetWrapper(Handle<Script> script) { |
12758 Isolate* isolate = script->GetIsolate(); | 12774 Isolate* isolate = script->GetIsolate(); |
12759 if (!script->wrapper()->IsUndefined()) { | 12775 if (!script->wrapper()->IsUndefined(isolate)) { |
12760 DCHECK(script->wrapper()->IsWeakCell()); | 12776 DCHECK(script->wrapper()->IsWeakCell()); |
12761 Handle<WeakCell> cell(WeakCell::cast(script->wrapper())); | 12777 Handle<WeakCell> cell(WeakCell::cast(script->wrapper())); |
12762 if (!cell->cleared()) { | 12778 if (!cell->cleared()) { |
12763 // Return a handle for the existing script wrapper from the cache. | 12779 // Return a handle for the existing script wrapper from the cache. |
12764 return handle(JSObject::cast(cell->value())); | 12780 return handle(JSObject::cast(cell->value())); |
12765 } | 12781 } |
12766 // If we found an empty WeakCell, that means the script wrapper was | 12782 // If we found an empty WeakCell, that means the script wrapper was |
12767 // GCed. We are not notified directly of that, so we decrement here | 12783 // GCed. We are not notified directly of that, so we decrement here |
12768 // so that we at least don't count double for any given script. | 12784 // so that we at least don't count double for any given script. |
12769 isolate->counters()->script_wrappers()->Decrement(); | 12785 isolate->counters()->script_wrappers()->Decrement(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12914 return true; | 12930 return true; |
12915 } | 12931 } |
12916 if (filter[filter.length() - 1] == '*' && | 12932 if (filter[filter.length() - 1] == '*' && |
12917 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { | 12933 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { |
12918 return true; | 12934 return true; |
12919 } | 12935 } |
12920 return false; | 12936 return false; |
12921 } | 12937 } |
12922 | 12938 |
12923 bool SharedFunctionInfo::HasSourceCode() const { | 12939 bool SharedFunctionInfo::HasSourceCode() const { |
12924 return !script()->IsUndefined() && | 12940 Isolate* isolate = GetIsolate(); |
12925 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); | 12941 return !script()->IsUndefined(isolate) && |
| 12942 !reinterpret_cast<Script*>(script())->source()->IsUndefined(isolate); |
12926 } | 12943 } |
12927 | 12944 |
12928 | 12945 |
12929 Handle<Object> SharedFunctionInfo::GetSourceCode() { | 12946 Handle<Object> SharedFunctionInfo::GetSourceCode() { |
12930 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 12947 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
12931 Handle<String> source(String::cast(Script::cast(script())->source())); | 12948 Handle<String> source(String::cast(Script::cast(script())->source())); |
12932 return GetIsolate()->factory()->NewSubString( | 12949 return GetIsolate()->factory()->NewSubString( |
12933 source, start_position(), end_position()); | 12950 source, start_position(), end_position()); |
12934 } | 12951 } |
12935 | 12952 |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14242 | 14259 |
14243 for (uint32_t i = 0; i < back_edges.length(); i++) { | 14260 for (uint32_t i = 0; i < back_edges.length(); i++) { |
14244 os << std::setw(6) << back_edges.ast_id(i).ToInt() << " " | 14261 os << std::setw(6) << back_edges.ast_id(i).ToInt() << " " |
14245 << std::setw(9) << back_edges.pc_offset(i) << " " << std::setw(10) | 14262 << std::setw(9) << back_edges.pc_offset(i) << " " << std::setw(10) |
14246 << back_edges.loop_depth(i) << "\n"; | 14263 << back_edges.loop_depth(i) << "\n"; |
14247 } | 14264 } |
14248 | 14265 |
14249 os << "\n"; | 14266 os << "\n"; |
14250 } | 14267 } |
14251 #ifdef OBJECT_PRINT | 14268 #ifdef OBJECT_PRINT |
14252 if (!type_feedback_info()->IsUndefined()) { | 14269 if (!type_feedback_info()->IsUndefined(GetIsolate())) { |
14253 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); | 14270 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); |
14254 os << "\n"; | 14271 os << "\n"; |
14255 } | 14272 } |
14256 #endif | 14273 #endif |
14257 } | 14274 } |
14258 | 14275 |
14259 if (handler_table()->length() > 0) { | 14276 if (handler_table()->length() > 0) { |
14260 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; | 14277 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; |
14261 if (kind() == FUNCTION) { | 14278 if (kind() == FUNCTION) { |
14262 HandlerTable::cast(handler_table())->HandlerTableRangePrint(os); | 14279 HandlerTable::cast(handler_table())->HandlerTableRangePrint(os); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14714 } | 14731 } |
14715 // 5. Let target be the value of the [[ProxyTarget]] internal slot. | 14732 // 5. Let target be the value of the [[ProxyTarget]] internal slot. |
14716 Handle<JSReceiver> target(proxy->target(), isolate); | 14733 Handle<JSReceiver> target(proxy->target(), isolate); |
14717 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). | 14734 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). |
14718 Handle<Object> trap; | 14735 Handle<Object> trap; |
14719 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 14736 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
14720 isolate, trap, | 14737 isolate, trap, |
14721 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), | 14738 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), |
14722 Nothing<bool>()); | 14739 Nothing<bool>()); |
14723 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). | 14740 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). |
14724 if (trap->IsUndefined()) { | 14741 if (trap->IsUndefined(isolate)) { |
14725 return JSReceiver::SetPrototype(target, value, from_javascript, | 14742 return JSReceiver::SetPrototype(target, value, from_javascript, |
14726 should_throw); | 14743 should_throw); |
14727 } | 14744 } |
14728 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). | 14745 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). |
14729 Handle<Object> argv[] = {target, value}; | 14746 Handle<Object> argv[] = {target, value}; |
14730 Handle<Object> trap_result; | 14747 Handle<Object> trap_result; |
14731 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 14748 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
14732 isolate, trap_result, | 14749 isolate, trap_result, |
14733 Execution::Call(isolate, trap, handler, arraysize(argv), argv), | 14750 Execution::Call(isolate, trap, handler, arraysize(argv), argv), |
14734 Nothing<bool>()); | 14751 Nothing<bool>()); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15362 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, | 15379 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, |
15363 bool* done) { | 15380 bool* done) { |
15364 *done = false; | 15381 *done = false; |
15365 Isolate* isolate = it->isolate(); | 15382 Isolate* isolate = it->isolate(); |
15366 // Make sure that the top context does not change when doing callbacks or | 15383 // Make sure that the top context does not change when doing callbacks or |
15367 // interceptor calls. | 15384 // interceptor calls. |
15368 AssertNoContextChange ncc(isolate); | 15385 AssertNoContextChange ncc(isolate); |
15369 | 15386 |
15370 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); | 15387 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); |
15371 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); | 15388 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); |
15372 if (interceptor->getter()->IsUndefined()) { | 15389 if (interceptor->getter()->IsUndefined(isolate)) { |
15373 return isolate->factory()->undefined_value(); | 15390 return isolate->factory()->undefined_value(); |
15374 } | 15391 } |
15375 | 15392 |
15376 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 15393 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
15377 Handle<Object> result; | 15394 Handle<Object> result; |
15378 Handle<Object> receiver = it->GetReceiver(); | 15395 Handle<Object> receiver = it->GetReceiver(); |
15379 if (!receiver->IsJSReceiver()) { | 15396 if (!receiver->IsJSReceiver()) { |
15380 ASSIGN_RETURN_ON_EXCEPTION( | 15397 ASSIGN_RETURN_ON_EXCEPTION( |
15381 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object); | 15398 isolate, receiver, Object::ConvertReceiver(isolate, receiver), Object); |
15382 } | 15399 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15621 #define SYMBOL_CHECK_AND_PRINT(name) \ | 15638 #define SYMBOL_CHECK_AND_PRINT(name) \ |
15622 if (this == heap->name()) return #name; | 15639 if (this == heap->name()) return #name; |
15623 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT) | 15640 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT) |
15624 #undef SYMBOL_CHECK_AND_PRINT | 15641 #undef SYMBOL_CHECK_AND_PRINT |
15625 return "UNKNOWN"; | 15642 return "UNKNOWN"; |
15626 } | 15643 } |
15627 | 15644 |
15628 | 15645 |
15629 void Symbol::SymbolShortPrint(std::ostream& os) { | 15646 void Symbol::SymbolShortPrint(std::ostream& os) { |
15630 os << "<Symbol:"; | 15647 os << "<Symbol:"; |
15631 if (!name()->IsUndefined()) { | 15648 if (!name()->IsUndefined(GetIsolate())) { |
15632 os << " "; | 15649 os << " "; |
15633 HeapStringAllocator allocator; | 15650 HeapStringAllocator allocator; |
15634 StringStream accumulator(&allocator); | 15651 StringStream accumulator(&allocator); |
15635 String::cast(name())->StringShortPrint(&accumulator, false); | 15652 String::cast(name())->StringShortPrint(&accumulator, false); |
15636 os << accumulator.ToCString().get(); | 15653 os << accumulator.ToCString().get(); |
15637 } else { | 15654 } else { |
15638 os << " (" << PrivateSymbolToName() << ")"; | 15655 os << " (" << PrivateSymbolToName() << ")"; |
15639 } | 15656 } |
15640 os << ">"; | 15657 os << ">"; |
15641 } | 15658 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16058 // 3. Detect a case when a dictionary key is not unique but the key is. | 16075 // 3. Detect a case when a dictionary key is not unique but the key is. |
16059 // In case of positive result the dictionary key may be replaced by the | 16076 // In case of positive result the dictionary key may be replaced by the |
16060 // internalized string with minimal performance penalty. It gives a chance | 16077 // internalized string with minimal performance penalty. It gives a chance |
16061 // to perform further lookups in code stubs (and significant performance | 16078 // to perform further lookups in code stubs (and significant performance |
16062 // boost a certain style of code). | 16079 // boost a certain style of code). |
16063 | 16080 |
16064 // EnsureCapacity will guarantee the hash table is never full. | 16081 // EnsureCapacity will guarantee the hash table is never full. |
16065 uint32_t capacity = this->Capacity(); | 16082 uint32_t capacity = this->Capacity(); |
16066 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); | 16083 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); |
16067 uint32_t count = 1; | 16084 uint32_t count = 1; |
16068 | 16085 Isolate* isolate = this->GetIsolate(); |
16069 while (true) { | 16086 while (true) { |
16070 int index = Derived::EntryToIndex(entry); | 16087 int index = Derived::EntryToIndex(entry); |
16071 Object* element = this->get(index); | 16088 Object* element = this->get(index); |
16072 if (element->IsUndefined()) break; // Empty entry. | 16089 if (element->IsUndefined(isolate)) break; // Empty entry. |
16073 if (*key == element) return entry; | 16090 if (*key == element) return entry; |
16074 DCHECK(element->IsTheHole() || element->IsUniqueName()); | 16091 DCHECK(element->IsTheHole(isolate) || element->IsUniqueName()); |
16075 entry = Derived::NextProbe(entry, count++, capacity); | 16092 entry = Derived::NextProbe(entry, count++, capacity); |
16076 } | 16093 } |
16077 return Derived::kNotFound; | 16094 return Derived::kNotFound; |
16078 } | 16095 } |
16079 | 16096 |
16080 | 16097 |
16081 template<typename Derived, typename Shape, typename Key> | 16098 template<typename Derived, typename Shape, typename Key> |
16082 void HashTable<Derived, Shape, Key>::Rehash( | 16099 void HashTable<Derived, Shape, Key>::Rehash( |
16083 Handle<Derived> new_table, | 16100 Handle<Derived> new_table, |
16084 Key key) { | 16101 Key key) { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16484 Handle<Object> value(dict->ValueAt(i), isolate); | 16501 Handle<Object> value(dict->ValueAt(i), isolate); |
16485 PropertyDetails details = dict->DetailsAt(i); | 16502 PropertyDetails details = dict->DetailsAt(i); |
16486 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) { | 16503 if (details.type() == ACCESSOR_CONSTANT || details.IsReadOnly()) { |
16487 // Bail out and do the sorting of undefineds and array holes in JS. | 16504 // Bail out and do the sorting of undefineds and array holes in JS. |
16488 // Also bail out if the element is not supposed to be moved. | 16505 // Also bail out if the element is not supposed to be moved. |
16489 return bailout; | 16506 return bailout; |
16490 } | 16507 } |
16491 | 16508 |
16492 uint32_t key = NumberToUint32(k); | 16509 uint32_t key = NumberToUint32(k); |
16493 if (key < limit) { | 16510 if (key < limit) { |
16494 if (value->IsUndefined()) { | 16511 if (value->IsUndefined(isolate)) { |
16495 undefs++; | 16512 undefs++; |
16496 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { | 16513 } else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { |
16497 // Adding an entry with the key beyond smi-range requires | 16514 // Adding an entry with the key beyond smi-range requires |
16498 // allocation. Bailout. | 16515 // allocation. Bailout. |
16499 return bailout; | 16516 return bailout; |
16500 } else { | 16517 } else { |
16501 Handle<Object> result = SeededNumberDictionary::AddNumberEntry( | 16518 Handle<Object> result = SeededNumberDictionary::AddNumberEntry( |
16502 new_dict, pos, value, details, object->map()->is_prototype_map()); | 16519 new_dict, pos, value, details, object->map()->is_prototype_map()); |
16503 DCHECK(result.is_identical_to(new_dict)); | 16520 DCHECK(result.is_identical_to(new_dict)); |
16504 USE(result); | 16521 USE(result); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16634 | 16651 |
16635 // Split elements into defined, undefined and the_hole, in that order. Only | 16652 // Split elements into defined, undefined and the_hole, in that order. Only |
16636 // count locations for undefined and the hole, and fill them afterwards. | 16653 // count locations for undefined and the hole, and fill them afterwards. |
16637 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc); | 16654 WriteBarrierMode write_barrier = elements->GetWriteBarrierMode(no_gc); |
16638 unsigned int undefs = limit; | 16655 unsigned int undefs = limit; |
16639 unsigned int holes = limit; | 16656 unsigned int holes = limit; |
16640 // Assume most arrays contain no holes and undefined values, so minimize the | 16657 // Assume most arrays contain no holes and undefined values, so minimize the |
16641 // number of stores of non-undefined, non-the-hole values. | 16658 // number of stores of non-undefined, non-the-hole values. |
16642 for (unsigned int i = 0; i < undefs; i++) { | 16659 for (unsigned int i = 0; i < undefs; i++) { |
16643 Object* current = elements->get(i); | 16660 Object* current = elements->get(i); |
16644 if (current->IsTheHole()) { | 16661 if (current->IsTheHole(isolate)) { |
16645 holes--; | 16662 holes--; |
16646 undefs--; | 16663 undefs--; |
16647 } else if (current->IsUndefined()) { | 16664 } else if (current->IsUndefined(isolate)) { |
16648 undefs--; | 16665 undefs--; |
16649 } else { | 16666 } else { |
16650 continue; | 16667 continue; |
16651 } | 16668 } |
16652 // Position i needs to be filled. | 16669 // Position i needs to be filled. |
16653 while (undefs > i) { | 16670 while (undefs > i) { |
16654 current = elements->get(undefs); | 16671 current = elements->get(undefs); |
16655 if (current->IsTheHole()) { | 16672 if (current->IsTheHole(isolate)) { |
16656 holes--; | 16673 holes--; |
16657 undefs--; | 16674 undefs--; |
16658 } else if (current->IsUndefined()) { | 16675 } else if (current->IsUndefined(isolate)) { |
16659 undefs--; | 16676 undefs--; |
16660 } else { | 16677 } else { |
16661 elements->set(i, current, write_barrier); | 16678 elements->set(i, current, write_barrier); |
16662 break; | 16679 break; |
16663 } | 16680 } |
16664 } | 16681 } |
16665 } | 16682 } |
16666 result = undefs; | 16683 result = undefs; |
16667 while (undefs < holes) { | 16684 while (undefs < holes) { |
16668 elements->set_undefined(undefs); | 16685 elements->set_undefined(undefs); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16716 auto dictionary = handle(global->global_dictionary()); | 16733 auto dictionary = handle(global->global_dictionary()); |
16717 int entry = dictionary->FindEntry(name); | 16734 int entry = dictionary->FindEntry(name); |
16718 if (entry == GlobalDictionary::kNotFound) return; | 16735 if (entry == GlobalDictionary::kNotFound) return; |
16719 PropertyCell::InvalidateEntry(dictionary, entry); | 16736 PropertyCell::InvalidateEntry(dictionary, entry); |
16720 } | 16737 } |
16721 | 16738 |
16722 | 16739 |
16723 // TODO(ishell): rename to EnsureEmptyPropertyCell or something. | 16740 // TODO(ishell): rename to EnsureEmptyPropertyCell or something. |
16724 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( | 16741 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( |
16725 Handle<JSGlobalObject> global, Handle<Name> name) { | 16742 Handle<JSGlobalObject> global, Handle<Name> name) { |
| 16743 Isolate* isolate = global->GetIsolate(); |
16726 DCHECK(!global->HasFastProperties()); | 16744 DCHECK(!global->HasFastProperties()); |
16727 auto dictionary = handle(global->global_dictionary()); | 16745 auto dictionary = handle(global->global_dictionary(), isolate); |
16728 int entry = dictionary->FindEntry(name); | 16746 int entry = dictionary->FindEntry(name); |
16729 Handle<PropertyCell> cell; | 16747 Handle<PropertyCell> cell; |
16730 if (entry != GlobalDictionary::kNotFound) { | 16748 if (entry != GlobalDictionary::kNotFound) { |
16731 // This call should be idempotent. | 16749 // This call should be idempotent. |
16732 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 16750 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
16733 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); | 16751 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); |
16734 DCHECK(cell->property_details().cell_type() == | 16752 DCHECK(cell->property_details().cell_type() == |
16735 PropertyCellType::kUninitialized || | 16753 PropertyCellType::kUninitialized || |
16736 cell->property_details().cell_type() == | 16754 cell->property_details().cell_type() == |
16737 PropertyCellType::kInvalidated); | 16755 PropertyCellType::kInvalidated); |
16738 DCHECK(cell->value()->IsTheHole()); | 16756 DCHECK(cell->value()->IsTheHole(isolate)); |
16739 return cell; | 16757 return cell; |
16740 } | 16758 } |
16741 Isolate* isolate = global->GetIsolate(); | |
16742 cell = isolate->factory()->NewPropertyCell(); | 16759 cell = isolate->factory()->NewPropertyCell(); |
16743 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); | 16760 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); |
16744 dictionary = GlobalDictionary::Add(dictionary, name, cell, details); | 16761 dictionary = GlobalDictionary::Add(dictionary, name, cell, details); |
16745 global->set_properties(*dictionary); | 16762 global->set_properties(*dictionary); |
16746 return cell; | 16763 return cell; |
16747 } | 16764 } |
16748 | 16765 |
16749 | 16766 |
16750 // This class is used for looking up two character strings in the string table. | 16767 // This class is used for looking up two character strings in the string table. |
16751 // If we don't have a hit we don't want to waste much time so we unroll the | 16768 // 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 Loading... |
17515 | 17532 |
17516 | 17533 |
17517 Object* ObjectHashTable::Lookup(Handle<Object> key) { | 17534 Object* ObjectHashTable::Lookup(Handle<Object> key) { |
17518 DisallowHeapAllocation no_gc; | 17535 DisallowHeapAllocation no_gc; |
17519 DCHECK(IsKey(*key)); | 17536 DCHECK(IsKey(*key)); |
17520 | 17537 |
17521 Isolate* isolate = GetIsolate(); | 17538 Isolate* isolate = GetIsolate(); |
17522 | 17539 |
17523 // If the object does not have an identity hash, it was never used as a key. | 17540 // If the object does not have an identity hash, it was never used as a key. |
17524 Object* hash = key->GetHash(); | 17541 Object* hash = key->GetHash(); |
17525 if (hash->IsUndefined()) { | 17542 if (hash->IsUndefined(isolate)) { |
17526 return isolate->heap()->the_hole_value(); | 17543 return isolate->heap()->the_hole_value(); |
17527 } | 17544 } |
17528 return Lookup(isolate, key, Smi::cast(hash)->value()); | 17545 return Lookup(isolate, key, Smi::cast(hash)->value()); |
17529 } | 17546 } |
17530 | 17547 |
17531 | 17548 |
17532 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) { | 17549 Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) { |
17533 return Lookup(GetIsolate(), key, hash); | 17550 return Lookup(GetIsolate(), key, hash); |
17534 } | 17551 } |
17535 | 17552 |
17536 | 17553 |
17537 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, | 17554 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
17538 Handle<Object> key, | 17555 Handle<Object> key, |
17539 Handle<Object> value) { | 17556 Handle<Object> value) { |
| 17557 Isolate* isolate = table->GetIsolate(); |
| 17558 |
17540 DCHECK(table->IsKey(*key)); | 17559 DCHECK(table->IsKey(*key)); |
17541 DCHECK(!value->IsTheHole()); | 17560 DCHECK(!value->IsTheHole(isolate)); |
17542 | 17561 |
17543 Isolate* isolate = table->GetIsolate(); | |
17544 // Make sure the key object has an identity hash code. | 17562 // Make sure the key object has an identity hash code. |
17545 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); | 17563 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); |
17546 | 17564 |
17547 return Put(table, key, value, hash); | 17565 return Put(table, key, value, hash); |
17548 } | 17566 } |
17549 | 17567 |
17550 | 17568 |
17551 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, | 17569 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
17552 Handle<Object> key, | 17570 Handle<Object> key, |
17553 Handle<Object> value, | 17571 Handle<Object> value, |
17554 int32_t hash) { | 17572 int32_t hash) { |
| 17573 Isolate* isolate = table->GetIsolate(); |
| 17574 |
17555 DCHECK(table->IsKey(*key)); | 17575 DCHECK(table->IsKey(*key)); |
17556 DCHECK(!value->IsTheHole()); | 17576 DCHECK(!value->IsTheHole(isolate)); |
17557 | |
17558 Isolate* isolate = table->GetIsolate(); | |
17559 | 17577 |
17560 int entry = table->FindEntry(isolate, key, hash); | 17578 int entry = table->FindEntry(isolate, key, hash); |
17561 | 17579 |
17562 // Key is already in table, just overwrite value. | 17580 // Key is already in table, just overwrite value. |
17563 if (entry != kNotFound) { | 17581 if (entry != kNotFound) { |
17564 table->set(EntryToIndex(entry) + 1, *value); | 17582 table->set(EntryToIndex(entry) + 1, *value); |
17565 return table; | 17583 return table; |
17566 } | 17584 } |
17567 | 17585 |
17568 // Rehash if more than 33% of the entries are deleted entries. | 17586 // Rehash if more than 33% of the entries are deleted entries. |
17569 // TODO(jochen): Consider to shrink the fixed array in place. | 17587 // TODO(jochen): Consider to shrink the fixed array in place. |
17570 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { | 17588 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { |
17571 table->Rehash(isolate->factory()->undefined_value()); | 17589 table->Rehash(isolate->factory()->undefined_value()); |
17572 } | 17590 } |
17573 | 17591 |
17574 // Check whether the hash table should be extended. | 17592 // Check whether the hash table should be extended. |
17575 table = EnsureCapacity(table, 1, key); | 17593 table = EnsureCapacity(table, 1, key); |
17576 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | 17594 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); |
17577 return table; | 17595 return table; |
17578 } | 17596 } |
17579 | 17597 |
17580 | 17598 |
17581 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, | 17599 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
17582 Handle<Object> key, | 17600 Handle<Object> key, |
17583 bool* was_present) { | 17601 bool* was_present) { |
17584 DCHECK(table->IsKey(*key)); | 17602 DCHECK(table->IsKey(*key)); |
17585 | 17603 |
17586 Object* hash = key->GetHash(); | 17604 Object* hash = key->GetHash(); |
17587 if (hash->IsUndefined()) { | 17605 if (hash->IsUndefined(table->GetIsolate())) { |
17588 *was_present = false; | 17606 *was_present = false; |
17589 return table; | 17607 return table; |
17590 } | 17608 } |
17591 | 17609 |
17592 return Remove(table, key, was_present, Smi::cast(hash)->value()); | 17610 return Remove(table, key, was_present, Smi::cast(hash)->value()); |
17593 } | 17611 } |
17594 | 17612 |
17595 | 17613 |
17596 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, | 17614 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
17597 Handle<Object> key, | 17615 Handle<Object> key, |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17915 } | 17933 } |
17916 | 17934 |
17917 set_table(table); | 17935 set_table(table); |
17918 set_index(Smi::FromInt(index)); | 17936 set_index(Smi::FromInt(index)); |
17919 } | 17937 } |
17920 | 17938 |
17921 | 17939 |
17922 template<class Derived, class TableType> | 17940 template<class Derived, class TableType> |
17923 bool OrderedHashTableIterator<Derived, TableType>::HasMore() { | 17941 bool OrderedHashTableIterator<Derived, TableType>::HasMore() { |
17924 DisallowHeapAllocation no_allocation; | 17942 DisallowHeapAllocation no_allocation; |
17925 if (this->table()->IsUndefined()) return false; | 17943 Isolate* isolate = this->GetIsolate(); |
| 17944 if (this->table()->IsUndefined(isolate)) return false; |
17926 | 17945 |
17927 Transition(); | 17946 Transition(); |
17928 | 17947 |
17929 TableType* table = TableType::cast(this->table()); | 17948 TableType* table = TableType::cast(this->table()); |
17930 int index = Smi::cast(this->index())->value(); | 17949 int index = Smi::cast(this->index())->value(); |
17931 int used_capacity = table->UsedCapacity(); | 17950 int used_capacity = table->UsedCapacity(); |
17932 | 17951 |
17933 while (index < used_capacity && table->KeyAt(index)->IsTheHole()) { | 17952 while (index < used_capacity && table->KeyAt(index)->IsTheHole(isolate)) { |
17934 index++; | 17953 index++; |
17935 } | 17954 } |
17936 | 17955 |
17937 set_index(Smi::FromInt(index)); | 17956 set_index(Smi::FromInt(index)); |
17938 | 17957 |
17939 if (index < used_capacity) return true; | 17958 if (index < used_capacity) return true; |
17940 | 17959 |
17941 set_table(GetHeap()->undefined_value()); | 17960 set_table(isolate->heap()->undefined_value()); |
17942 return false; | 17961 return false; |
17943 } | 17962 } |
17944 | 17963 |
17945 | 17964 |
17946 template<class Derived, class TableType> | 17965 template<class Derived, class TableType> |
17947 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { | 17966 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { |
17948 DisallowHeapAllocation no_allocation; | 17967 DisallowHeapAllocation no_allocation; |
17949 if (HasMore()) { | 17968 if (HasMore()) { |
17950 FixedArray* array = FixedArray::cast(value_array->elements()); | 17969 FixedArray* array = FixedArray::cast(value_array->elements()); |
17951 static_cast<Derived*>(this)->PopulateValueArray(array); | 17970 static_cast<Derived*>(this)->PopulateValueArray(array); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18057 return was_present; | 18076 return was_present; |
18058 } | 18077 } |
18059 | 18078 |
18060 // Check if there is a break point at this code offset. | 18079 // Check if there is a break point at this code offset. |
18061 bool DebugInfo::HasBreakPoint(int code_offset) { | 18080 bool DebugInfo::HasBreakPoint(int code_offset) { |
18062 // Get the break point info object for this code offset. | 18081 // Get the break point info object for this code offset. |
18063 Object* break_point_info = GetBreakPointInfo(code_offset); | 18082 Object* break_point_info = GetBreakPointInfo(code_offset); |
18064 | 18083 |
18065 // If there is no break point info object or no break points in the break | 18084 // If there is no break point info object or no break points in the break |
18066 // point info object there is no break point at this code offset. | 18085 // point info object there is no break point at this code offset. |
18067 if (break_point_info->IsUndefined()) return false; | 18086 if (break_point_info->IsUndefined(GetIsolate())) return false; |
18068 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; | 18087 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; |
18069 } | 18088 } |
18070 | 18089 |
18071 // Get the break point info object for this code offset. | 18090 // Get the break point info object for this code offset. |
18072 Object* DebugInfo::GetBreakPointInfo(int code_offset) { | 18091 Object* DebugInfo::GetBreakPointInfo(int code_offset) { |
18073 // Find the index of the break point info object for this code offset. | 18092 // Find the index of the break point info object for this code offset. |
18074 int index = GetBreakPointInfoIndex(code_offset); | 18093 int index = GetBreakPointInfoIndex(code_offset); |
18075 | 18094 |
18076 // Return the break point info object if any. | 18095 // Return the break point info object if any. |
18077 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); | 18096 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); |
18078 return BreakPointInfo::cast(break_points()->get(index)); | 18097 return BreakPointInfo::cast(break_points()->get(index)); |
18079 } | 18098 } |
18080 | 18099 |
18081 // Clear a break point at the specified code offset. | 18100 // Clear a break point at the specified code offset. |
18082 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, | 18101 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
18083 Handle<Object> break_point_object) { | 18102 Handle<Object> break_point_object) { |
| 18103 Isolate* isolate = debug_info->GetIsolate(); |
18084 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), | 18104 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), |
18085 debug_info->GetIsolate()); | 18105 isolate); |
18086 if (break_point_info->IsUndefined()) return; | 18106 if (break_point_info->IsUndefined(isolate)) return; |
18087 BreakPointInfo::ClearBreakPoint( | 18107 BreakPointInfo::ClearBreakPoint( |
18088 Handle<BreakPointInfo>::cast(break_point_info), | 18108 Handle<BreakPointInfo>::cast(break_point_info), |
18089 break_point_object); | 18109 break_point_object); |
18090 } | 18110 } |
18091 | 18111 |
18092 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, | 18112 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
18093 int source_position, int statement_position, | 18113 int source_position, int statement_position, |
18094 Handle<Object> break_point_object) { | 18114 Handle<Object> break_point_object) { |
18095 Isolate* isolate = debug_info->GetIsolate(); | 18115 Isolate* isolate = debug_info->GetIsolate(); |
18096 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), | 18116 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), |
18097 isolate); | 18117 isolate); |
18098 if (!break_point_info->IsUndefined()) { | 18118 if (!break_point_info->IsUndefined(isolate)) { |
18099 BreakPointInfo::SetBreakPoint( | 18119 BreakPointInfo::SetBreakPoint( |
18100 Handle<BreakPointInfo>::cast(break_point_info), | 18120 Handle<BreakPointInfo>::cast(break_point_info), |
18101 break_point_object); | 18121 break_point_object); |
18102 return; | 18122 return; |
18103 } | 18123 } |
18104 | 18124 |
18105 // Adding a new break point for a code offset which did not have any | 18125 // Adding a new break point for a code offset which did not have any |
18106 // break points before. Try to find a free slot. | 18126 // break points before. Try to find a free slot. |
18107 int index = kNoBreakPointInfo; | 18127 int index = kNoBreakPointInfo; |
18108 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 18128 for (int i = 0; i < debug_info->break_points()->length(); i++) { |
18109 if (debug_info->break_points()->get(i)->IsUndefined()) { | 18129 if (debug_info->break_points()->get(i)->IsUndefined(isolate)) { |
18110 index = i; | 18130 index = i; |
18111 break; | 18131 break; |
18112 } | 18132 } |
18113 } | 18133 } |
18114 if (index == kNoBreakPointInfo) { | 18134 if (index == kNoBreakPointInfo) { |
18115 // No free slot - extend break point info array. | 18135 // No free slot - extend break point info array. |
18116 Handle<FixedArray> old_break_points = | 18136 Handle<FixedArray> old_break_points = Handle<FixedArray>( |
18117 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); | 18137 FixedArray::cast(debug_info->break_points()), isolate); |
18118 Handle<FixedArray> new_break_points = | 18138 Handle<FixedArray> new_break_points = |
18119 isolate->factory()->NewFixedArray( | 18139 isolate->factory()->NewFixedArray( |
18120 old_break_points->length() + | 18140 old_break_points->length() + |
18121 DebugInfo::kEstimatedNofBreakPointsInFunction); | 18141 DebugInfo::kEstimatedNofBreakPointsInFunction); |
18122 | 18142 |
18123 debug_info->set_break_points(*new_break_points); | 18143 debug_info->set_break_points(*new_break_points); |
18124 for (int i = 0; i < old_break_points->length(); i++) { | 18144 for (int i = 0; i < old_break_points->length(); i++) { |
18125 new_break_points->set(i, old_break_points->get(i)); | 18145 new_break_points->set(i, old_break_points->get(i)); |
18126 } | 18146 } |
18127 index = old_break_points->length(); | 18147 index = old_break_points->length(); |
18128 } | 18148 } |
18129 DCHECK(index != kNoBreakPointInfo); | 18149 DCHECK(index != kNoBreakPointInfo); |
18130 | 18150 |
18131 // Allocate new BreakPointInfo object and set the break point. | 18151 // Allocate new BreakPointInfo object and set the break point. |
18132 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( | 18152 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( |
18133 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); | 18153 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); |
18134 new_break_point_info->set_code_offset(code_offset); | 18154 new_break_point_info->set_code_offset(code_offset); |
18135 new_break_point_info->set_source_position(source_position); | 18155 new_break_point_info->set_source_position(source_position); |
18136 new_break_point_info->set_statement_position(statement_position); | 18156 new_break_point_info->set_statement_position(statement_position); |
18137 new_break_point_info->set_break_point_objects( | 18157 new_break_point_info->set_break_point_objects( |
18138 isolate->heap()->undefined_value()); | 18158 isolate->heap()->undefined_value()); |
18139 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); | 18159 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); |
18140 debug_info->break_points()->set(index, *new_break_point_info); | 18160 debug_info->break_points()->set(index, *new_break_point_info); |
18141 } | 18161 } |
18142 | 18162 |
18143 // Get the break point objects for a code offset. | 18163 // Get the break point objects for a code offset. |
18144 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { | 18164 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { |
18145 Object* break_point_info = GetBreakPointInfo(code_offset); | 18165 Object* break_point_info = GetBreakPointInfo(code_offset); |
18146 if (break_point_info->IsUndefined()) { | 18166 Isolate* isolate = GetIsolate(); |
18147 return GetIsolate()->factory()->undefined_value(); | 18167 if (break_point_info->IsUndefined(isolate)) { |
| 18168 return isolate->factory()->undefined_value(); |
18148 } | 18169 } |
18149 return Handle<Object>( | 18170 return Handle<Object>( |
18150 BreakPointInfo::cast(break_point_info)->break_point_objects(), | 18171 BreakPointInfo::cast(break_point_info)->break_point_objects(), isolate); |
18151 GetIsolate()); | |
18152 } | 18172 } |
18153 | 18173 |
18154 | 18174 |
18155 // Get the total number of break points. | 18175 // Get the total number of break points. |
18156 int DebugInfo::GetBreakPointCount() { | 18176 int DebugInfo::GetBreakPointCount() { |
18157 if (break_points()->IsUndefined()) return 0; | 18177 Isolate* isolate = GetIsolate(); |
| 18178 if (break_points()->IsUndefined(isolate)) return 0; |
18158 int count = 0; | 18179 int count = 0; |
18159 for (int i = 0; i < break_points()->length(); i++) { | 18180 for (int i = 0; i < break_points()->length(); i++) { |
18160 if (!break_points()->get(i)->IsUndefined()) { | 18181 if (!break_points()->get(i)->IsUndefined(isolate)) { |
18161 BreakPointInfo* break_point_info = | 18182 BreakPointInfo* break_point_info = |
18162 BreakPointInfo::cast(break_points()->get(i)); | 18183 BreakPointInfo::cast(break_points()->get(i)); |
18163 count += break_point_info->GetBreakPointCount(); | 18184 count += break_point_info->GetBreakPointCount(); |
18164 } | 18185 } |
18165 } | 18186 } |
18166 return count; | 18187 return count; |
18167 } | 18188 } |
18168 | 18189 |
18169 | 18190 |
18170 Handle<Object> DebugInfo::FindBreakPointInfo( | 18191 Handle<Object> DebugInfo::FindBreakPointInfo( |
18171 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) { | 18192 Handle<DebugInfo> debug_info, Handle<Object> break_point_object) { |
18172 Isolate* isolate = debug_info->GetIsolate(); | 18193 Isolate* isolate = debug_info->GetIsolate(); |
18173 if (!debug_info->break_points()->IsUndefined()) { | 18194 if (!debug_info->break_points()->IsUndefined(isolate)) { |
18174 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 18195 for (int i = 0; i < debug_info->break_points()->length(); i++) { |
18175 if (!debug_info->break_points()->get(i)->IsUndefined()) { | 18196 if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) { |
18176 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>( | 18197 Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>( |
18177 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate); | 18198 BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate); |
18178 if (BreakPointInfo::HasBreakPointObject(break_point_info, | 18199 if (BreakPointInfo::HasBreakPointObject(break_point_info, |
18179 break_point_object)) { | 18200 break_point_object)) { |
18180 return break_point_info; | 18201 return break_point_info; |
18181 } | 18202 } |
18182 } | 18203 } |
18183 } | 18204 } |
18184 } | 18205 } |
18185 return isolate->factory()->undefined_value(); | 18206 return isolate->factory()->undefined_value(); |
18186 } | 18207 } |
18187 | 18208 |
18188 | 18209 |
18189 // Find the index of the break point info object for the specified code | 18210 // Find the index of the break point info object for the specified code |
18190 // position. | 18211 // position. |
18191 int DebugInfo::GetBreakPointInfoIndex(int code_offset) { | 18212 int DebugInfo::GetBreakPointInfoIndex(int code_offset) { |
18192 if (break_points()->IsUndefined()) return kNoBreakPointInfo; | 18213 Isolate* isolate = GetIsolate(); |
| 18214 if (break_points()->IsUndefined(isolate)) return kNoBreakPointInfo; |
18193 for (int i = 0; i < break_points()->length(); i++) { | 18215 for (int i = 0; i < break_points()->length(); i++) { |
18194 if (!break_points()->get(i)->IsUndefined()) { | 18216 if (!break_points()->get(i)->IsUndefined(isolate)) { |
18195 BreakPointInfo* break_point_info = | 18217 BreakPointInfo* break_point_info = |
18196 BreakPointInfo::cast(break_points()->get(i)); | 18218 BreakPointInfo::cast(break_points()->get(i)); |
18197 if (break_point_info->code_offset() == code_offset) { | 18219 if (break_point_info->code_offset() == code_offset) { |
18198 return i; | 18220 return i; |
18199 } | 18221 } |
18200 } | 18222 } |
18201 } | 18223 } |
18202 return kNoBreakPointInfo; | 18224 return kNoBreakPointInfo; |
18203 } | 18225 } |
18204 | 18226 |
18205 | 18227 |
18206 // Remove the specified break point object. | 18228 // Remove the specified break point object. |
18207 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, | 18229 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, |
18208 Handle<Object> break_point_object) { | 18230 Handle<Object> break_point_object) { |
18209 Isolate* isolate = break_point_info->GetIsolate(); | 18231 Isolate* isolate = break_point_info->GetIsolate(); |
18210 // If there are no break points just ignore. | 18232 // If there are no break points just ignore. |
18211 if (break_point_info->break_point_objects()->IsUndefined()) return; | 18233 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return; |
18212 // If there is a single break point clear it if it is the same. | 18234 // If there is a single break point clear it if it is the same. |
18213 if (!break_point_info->break_point_objects()->IsFixedArray()) { | 18235 if (!break_point_info->break_point_objects()->IsFixedArray()) { |
18214 if (break_point_info->break_point_objects() == *break_point_object) { | 18236 if (break_point_info->break_point_objects() == *break_point_object) { |
18215 break_point_info->set_break_point_objects( | 18237 break_point_info->set_break_point_objects( |
18216 isolate->heap()->undefined_value()); | 18238 isolate->heap()->undefined_value()); |
18217 } | 18239 } |
18218 return; | 18240 return; |
18219 } | 18241 } |
18220 // If there are multiple break points shrink the array | 18242 // If there are multiple break points shrink the array |
18221 DCHECK(break_point_info->break_point_objects()->IsFixedArray()); | 18243 DCHECK(break_point_info->break_point_objects()->IsFixedArray()); |
(...skipping 15 matching lines...) Expand all Loading... |
18237 if (found_count > 0) break_point_info->set_break_point_objects(*new_array); | 18259 if (found_count > 0) break_point_info->set_break_point_objects(*new_array); |
18238 } | 18260 } |
18239 | 18261 |
18240 | 18262 |
18241 // Add the specified break point object. | 18263 // Add the specified break point object. |
18242 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info, | 18264 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info, |
18243 Handle<Object> break_point_object) { | 18265 Handle<Object> break_point_object) { |
18244 Isolate* isolate = break_point_info->GetIsolate(); | 18266 Isolate* isolate = break_point_info->GetIsolate(); |
18245 | 18267 |
18246 // If there was no break point objects before just set it. | 18268 // If there was no break point objects before just set it. |
18247 if (break_point_info->break_point_objects()->IsUndefined()) { | 18269 if (break_point_info->break_point_objects()->IsUndefined(isolate)) { |
18248 break_point_info->set_break_point_objects(*break_point_object); | 18270 break_point_info->set_break_point_objects(*break_point_object); |
18249 return; | 18271 return; |
18250 } | 18272 } |
18251 // If the break point object is the same as before just ignore. | 18273 // If the break point object is the same as before just ignore. |
18252 if (break_point_info->break_point_objects() == *break_point_object) return; | 18274 if (break_point_info->break_point_objects() == *break_point_object) return; |
18253 // If there was one break point object before replace with array. | 18275 // If there was one break point object before replace with array. |
18254 if (!break_point_info->break_point_objects()->IsFixedArray()) { | 18276 if (!break_point_info->break_point_objects()->IsFixedArray()) { |
18255 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2); | 18277 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2); |
18256 array->set(0, break_point_info->break_point_objects()); | 18278 array->set(0, break_point_info->break_point_objects()); |
18257 array->set(1, *break_point_object); | 18279 array->set(1, *break_point_object); |
(...skipping 14 matching lines...) Expand all Loading... |
18272 // Add the new break point. | 18294 // Add the new break point. |
18273 new_array->set(old_array->length(), *break_point_object); | 18295 new_array->set(old_array->length(), *break_point_object); |
18274 break_point_info->set_break_point_objects(*new_array); | 18296 break_point_info->set_break_point_objects(*new_array); |
18275 } | 18297 } |
18276 | 18298 |
18277 | 18299 |
18278 bool BreakPointInfo::HasBreakPointObject( | 18300 bool BreakPointInfo::HasBreakPointObject( |
18279 Handle<BreakPointInfo> break_point_info, | 18301 Handle<BreakPointInfo> break_point_info, |
18280 Handle<Object> break_point_object) { | 18302 Handle<Object> break_point_object) { |
18281 // No break point. | 18303 // No break point. |
18282 if (break_point_info->break_point_objects()->IsUndefined()) return false; | 18304 Isolate* isolate = break_point_info->GetIsolate(); |
| 18305 if (break_point_info->break_point_objects()->IsUndefined(isolate)) { |
| 18306 return false; |
| 18307 } |
18283 // Single break point. | 18308 // Single break point. |
18284 if (!break_point_info->break_point_objects()->IsFixedArray()) { | 18309 if (!break_point_info->break_point_objects()->IsFixedArray()) { |
18285 return break_point_info->break_point_objects() == *break_point_object; | 18310 return break_point_info->break_point_objects() == *break_point_object; |
18286 } | 18311 } |
18287 // Multiple break points. | 18312 // Multiple break points. |
18288 FixedArray* array = FixedArray::cast(break_point_info->break_point_objects()); | 18313 FixedArray* array = FixedArray::cast(break_point_info->break_point_objects()); |
18289 for (int i = 0; i < array->length(); i++) { | 18314 for (int i = 0; i < array->length(); i++) { |
18290 if (array->get(i) == *break_point_object) { | 18315 if (array->get(i) == *break_point_object) { |
18291 return true; | 18316 return true; |
18292 } | 18317 } |
18293 } | 18318 } |
18294 return false; | 18319 return false; |
18295 } | 18320 } |
18296 | 18321 |
18297 | 18322 |
18298 // Get the number of break points. | 18323 // Get the number of break points. |
18299 int BreakPointInfo::GetBreakPointCount() { | 18324 int BreakPointInfo::GetBreakPointCount() { |
18300 // No break point. | 18325 // No break point. |
18301 if (break_point_objects()->IsUndefined()) return 0; | 18326 if (break_point_objects()->IsUndefined(GetIsolate())) return 0; |
18302 // Single break point. | 18327 // Single break point. |
18303 if (!break_point_objects()->IsFixedArray()) return 1; | 18328 if (!break_point_objects()->IsFixedArray()) return 1; |
18304 // Multiple break points. | 18329 // Multiple break points. |
18305 return FixedArray::cast(break_point_objects())->length(); | 18330 return FixedArray::cast(break_point_objects())->length(); |
18306 } | 18331 } |
18307 | 18332 |
18308 | 18333 |
18309 // static | 18334 // static |
18310 MaybeHandle<JSDate> JSDate::New(Handle<JSFunction> constructor, | 18335 MaybeHandle<JSDate> JSDate::New(Handle<JSFunction> constructor, |
18311 Handle<JSReceiver> new_target, double tv) { | 18336 Handle<JSReceiver> new_target, double tv) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18618 | 18643 |
18619 Handle<PropertyCell> PropertyCell::InvalidateEntry( | 18644 Handle<PropertyCell> PropertyCell::InvalidateEntry( |
18620 Handle<GlobalDictionary> dictionary, int entry) { | 18645 Handle<GlobalDictionary> dictionary, int entry) { |
18621 Isolate* isolate = dictionary->GetIsolate(); | 18646 Isolate* isolate = dictionary->GetIsolate(); |
18622 // Swap with a copy. | 18647 // Swap with a copy. |
18623 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 18648 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
18624 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 18649 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
18625 auto new_cell = isolate->factory()->NewPropertyCell(); | 18650 auto new_cell = isolate->factory()->NewPropertyCell(); |
18626 new_cell->set_value(cell->value()); | 18651 new_cell->set_value(cell->value()); |
18627 dictionary->ValueAtPut(entry, *new_cell); | 18652 dictionary->ValueAtPut(entry, *new_cell); |
18628 bool is_the_hole = cell->value()->IsTheHole(); | 18653 bool is_the_hole = cell->value()->IsTheHole(isolate); |
18629 // Cell is officially mutable henceforth. | 18654 // Cell is officially mutable henceforth. |
18630 PropertyDetails details = cell->property_details(); | 18655 PropertyDetails details = cell->property_details(); |
18631 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated | 18656 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated |
18632 : PropertyCellType::kMutable); | 18657 : PropertyCellType::kMutable); |
18633 new_cell->set_property_details(details); | 18658 new_cell->set_property_details(details); |
18634 // Old cell is ready for invalidation. | 18659 // Old cell is ready for invalidation. |
18635 if (is_the_hole) { | 18660 if (is_the_hole) { |
18636 cell->set_value(isolate->heap()->undefined_value()); | 18661 cell->set_value(isolate->heap()->undefined_value()); |
18637 } else { | 18662 } else { |
18638 cell->set_value(isolate->heap()->the_hole_value()); | 18663 cell->set_value(isolate->heap()->the_hole_value()); |
(...skipping 23 matching lines...) Expand all Loading... |
18662 HeapObject::cast(*value)->map()->is_stable(); | 18687 HeapObject::cast(*value)->map()->is_stable(); |
18663 } | 18688 } |
18664 return false; | 18689 return false; |
18665 } | 18690 } |
18666 | 18691 |
18667 | 18692 |
18668 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell, | 18693 PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell, |
18669 Handle<Object> value, | 18694 Handle<Object> value, |
18670 PropertyDetails details) { | 18695 PropertyDetails details) { |
18671 PropertyCellType type = details.cell_type(); | 18696 PropertyCellType type = details.cell_type(); |
18672 DCHECK(!value->IsTheHole()); | 18697 Isolate* isolate = cell->GetIsolate(); |
18673 if (cell->value()->IsTheHole()) { | 18698 DCHECK(!value->IsTheHole(isolate)); |
| 18699 if (cell->value()->IsTheHole(isolate)) { |
18674 switch (type) { | 18700 switch (type) { |
18675 // Only allow a cell to transition once into constant state. | 18701 // Only allow a cell to transition once into constant state. |
18676 case PropertyCellType::kUninitialized: | 18702 case PropertyCellType::kUninitialized: |
18677 if (value->IsUndefined()) return PropertyCellType::kUndefined; | 18703 if (value->IsUndefined(isolate)) return PropertyCellType::kUndefined; |
18678 return PropertyCellType::kConstant; | 18704 return PropertyCellType::kConstant; |
18679 case PropertyCellType::kInvalidated: | 18705 case PropertyCellType::kInvalidated: |
18680 return PropertyCellType::kMutable; | 18706 return PropertyCellType::kMutable; |
18681 default: | 18707 default: |
18682 UNREACHABLE(); | 18708 UNREACHABLE(); |
18683 return PropertyCellType::kMutable; | 18709 return PropertyCellType::kMutable; |
18684 } | 18710 } |
18685 } | 18711 } |
18686 switch (type) { | 18712 switch (type) { |
18687 case PropertyCellType::kUndefined: | 18713 case PropertyCellType::kUndefined: |
18688 return PropertyCellType::kConstant; | 18714 return PropertyCellType::kConstant; |
18689 case PropertyCellType::kConstant: | 18715 case PropertyCellType::kConstant: |
18690 if (*value == cell->value()) return PropertyCellType::kConstant; | 18716 if (*value == cell->value()) return PropertyCellType::kConstant; |
18691 // Fall through. | 18717 // Fall through. |
18692 case PropertyCellType::kConstantType: | 18718 case PropertyCellType::kConstantType: |
18693 if (RemainsConstantType(cell, value)) { | 18719 if (RemainsConstantType(cell, value)) { |
18694 return PropertyCellType::kConstantType; | 18720 return PropertyCellType::kConstantType; |
18695 } | 18721 } |
18696 // Fall through. | 18722 // Fall through. |
18697 case PropertyCellType::kMutable: | 18723 case PropertyCellType::kMutable: |
18698 return PropertyCellType::kMutable; | 18724 return PropertyCellType::kMutable; |
18699 } | 18725 } |
18700 UNREACHABLE(); | 18726 UNREACHABLE(); |
18701 return PropertyCellType::kMutable; | 18727 return PropertyCellType::kMutable; |
18702 } | 18728 } |
18703 | 18729 |
18704 | 18730 |
18705 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, | 18731 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, |
18706 Handle<Object> value, PropertyDetails details) { | 18732 Handle<Object> value, PropertyDetails details) { |
18707 DCHECK(!value->IsTheHole()); | 18733 Isolate* isolate = dictionary->GetIsolate(); |
| 18734 DCHECK(!value->IsTheHole(isolate)); |
18708 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 18735 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
18709 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 18736 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
18710 const PropertyDetails original_details = cell->property_details(); | 18737 const PropertyDetails original_details = cell->property_details(); |
18711 // Data accesses could be cached in ics or optimized code. | 18738 // Data accesses could be cached in ics or optimized code. |
18712 bool invalidate = | 18739 bool invalidate = |
18713 original_details.kind() == kData && details.kind() == kAccessor; | 18740 original_details.kind() == kData && details.kind() == kAccessor; |
18714 int index = original_details.dictionary_index(); | 18741 int index = original_details.dictionary_index(); |
18715 PropertyCellType old_type = original_details.cell_type(); | 18742 PropertyCellType old_type = original_details.cell_type(); |
18716 // Preserve the enumeration index unless the property was deleted or never | 18743 // Preserve the enumeration index unless the property was deleted or never |
18717 // initialized. | 18744 // initialized. |
18718 if (cell->value()->IsTheHole()) { | 18745 if (cell->value()->IsTheHole(isolate)) { |
18719 index = dictionary->NextEnumerationIndex(); | 18746 index = dictionary->NextEnumerationIndex(); |
18720 dictionary->SetNextEnumerationIndex(index + 1); | 18747 dictionary->SetNextEnumerationIndex(index + 1); |
18721 // Negative lookup cells must be invalidated. | 18748 // Negative lookup cells must be invalidated. |
18722 invalidate = true; | 18749 invalidate = true; |
18723 } | 18750 } |
18724 DCHECK(index > 0); | 18751 DCHECK(index > 0); |
18725 details = details.set_index(index); | 18752 details = details.set_index(index); |
18726 | 18753 |
18727 PropertyCellType new_type = UpdatedType(cell, value, original_details); | 18754 PropertyCellType new_type = UpdatedType(cell, value, original_details); |
18728 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); | 18755 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); |
18729 | 18756 |
18730 // Install new property details and cell value. | 18757 // Install new property details and cell value. |
18731 details = details.set_cell_type(new_type); | 18758 details = details.set_cell_type(new_type); |
18732 cell->set_property_details(details); | 18759 cell->set_property_details(details); |
18733 cell->set_value(*value); | 18760 cell->set_value(*value); |
18734 | 18761 |
18735 // Deopt when transitioning from a constant type. | 18762 // Deopt when transitioning from a constant type. |
18736 if (!invalidate && (old_type != new_type || | 18763 if (!invalidate && (old_type != new_type || |
18737 original_details.IsReadOnly() != details.IsReadOnly())) { | 18764 original_details.IsReadOnly() != details.IsReadOnly())) { |
18738 Isolate* isolate = dictionary->GetIsolate(); | |
18739 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18765 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18740 isolate, DependentCode::kPropertyCellChangedGroup); | 18766 isolate, DependentCode::kPropertyCellChangedGroup); |
18741 } | 18767 } |
18742 } | 18768 } |
18743 | 18769 |
18744 | 18770 |
18745 // static | 18771 // static |
18746 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 18772 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
18747 Handle<Object> new_value) { | 18773 Handle<Object> new_value) { |
18748 if (cell->value() != *new_value) { | 18774 if (cell->value() != *new_value) { |
18749 cell->set_value(*new_value); | 18775 cell->set_value(*new_value); |
18750 Isolate* isolate = cell->GetIsolate(); | 18776 Isolate* isolate = cell->GetIsolate(); |
18751 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18777 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18752 isolate, DependentCode::kPropertyCellChangedGroup); | 18778 isolate, DependentCode::kPropertyCellChangedGroup); |
18753 } | 18779 } |
18754 } | 18780 } |
18755 | 18781 |
18756 } // namespace internal | 18782 } // namespace internal |
18757 } // namespace v8 | 18783 } // namespace v8 |
OLD | NEW |