| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, | 212 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, |
| 213 js_object); | 213 js_object); |
| 214 if (!maybe_result->ToObject(&result)) return maybe_result; | 214 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 215 } | 215 } |
| 216 element_dictionary->ValueAtPut(i, result); | 216 element_dictionary->ValueAtPut(i, result); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 break; | 220 break; |
| 221 } | 221 } |
| 222 default: | 222 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: |
| 223 UNREACHABLE(); | 223 UNIMPLEMENTED(); |
| 224 break; |
| 225 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
| 226 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 227 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 228 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 229 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 230 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 231 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 232 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 233 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: |
| 234 case JSObject::FAST_DOUBLE_ELEMENTS: |
| 235 // No contained objects, nothing to do. |
| 224 break; | 236 break; |
| 225 } | 237 } |
| 226 return copy; | 238 return copy; |
| 227 } | 239 } |
| 228 | 240 |
| 229 | 241 |
| 230 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneLiteralBoilerplate) { | 242 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneLiteralBoilerplate) { |
| 231 CONVERT_CHECKED(JSObject, boilerplate, args[0]); | 243 CONVERT_CHECKED(JSObject, boilerplate, args[0]); |
| 232 return DeepCopyBoilerplate(isolate, boilerplate); | 244 return DeepCopyBoilerplate(isolate, boilerplate); |
| 233 } | 245 } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 } | 620 } |
| 609 | 621 |
| 610 | 622 |
| 611 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { |
| 612 ASSERT(args.length() == 1); | 624 ASSERT(args.length() == 1); |
| 613 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 625 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
| 614 return proxy->handler(); | 626 return proxy->handler(); |
| 615 } | 627 } |
| 616 | 628 |
| 617 | 629 |
| 630 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
| 631 ASSERT(args.length() == 1); |
| 632 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
| 633 proxy->Fix(); |
| 634 return isolate->heap()->undefined_value(); |
| 635 } |
| 636 |
| 637 |
| 618 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 638 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
| 619 NoHandleAllocation ha; | 639 NoHandleAllocation ha; |
| 620 ASSERT(args.length() == 1); | 640 ASSERT(args.length() == 1); |
| 621 Object* obj = args[0]; | 641 Object* obj = args[0]; |
| 622 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 642 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 623 return JSObject::cast(obj)->class_name(); | 643 return JSObject::cast(obj)->class_name(); |
| 624 } | 644 } |
| 625 | 645 |
| 626 | 646 |
| 627 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 647 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 } | 1165 } |
| 1146 // Fall-through and introduce the absent property by using | 1166 // Fall-through and introduce the absent property by using |
| 1147 // SetProperty. | 1167 // SetProperty. |
| 1148 } else { | 1168 } else { |
| 1149 // For const properties, we treat a callback with this name | 1169 // For const properties, we treat a callback with this name |
| 1150 // even in the prototype as a conflicting declaration. | 1170 // even in the prototype as a conflicting declaration. |
| 1151 if (is_const_property && (lookup.type() == CALLBACKS)) { | 1171 if (is_const_property && (lookup.type() == CALLBACKS)) { |
| 1152 return ThrowRedeclarationError(isolate, "const", name); | 1172 return ThrowRedeclarationError(isolate, "const", name); |
| 1153 } | 1173 } |
| 1154 // Otherwise, we check for locally conflicting declarations. | 1174 // Otherwise, we check for locally conflicting declarations. |
| 1155 if (is_local && (is_read_only || is_const_property)) { | 1175 if (is_local && is_const_property) { |
| 1156 const char* type = (is_read_only) ? "const" : "var"; | 1176 const char* type = (is_read_only) ? "const" : "var"; |
| 1157 return ThrowRedeclarationError(isolate, type, name); | 1177 return ThrowRedeclarationError(isolate, type, name); |
| 1158 } | 1178 } |
| 1159 // The property already exists without conflicting: Go to | 1179 // The property already exists without conflicting: Go to |
| 1160 // the next declaration. | 1180 // the next declaration. |
| 1161 continue; | 1181 continue; |
| 1162 } | 1182 } |
| 1163 } | 1183 } |
| 1164 } else { | 1184 } else { |
| 1165 // Copy the function and update its context. Use it as value. | 1185 // Copy the function and update its context. Use it as value. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 if (type == INTERCEPTOR) { | 1399 if (type == INTERCEPTOR) { |
| 1380 HandleScope handle_scope(isolate); | 1400 HandleScope handle_scope(isolate); |
| 1381 Handle<JSObject> holder(real_holder); | 1401 Handle<JSObject> holder(real_holder); |
| 1382 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); | 1402 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); |
| 1383 real_holder = *holder; | 1403 real_holder = *holder; |
| 1384 if (intercepted == ABSENT) { | 1404 if (intercepted == ABSENT) { |
| 1385 // The interceptor claims the property isn't there. We need to | 1405 // The interceptor claims the property isn't there. We need to |
| 1386 // make sure to introduce it. | 1406 // make sure to introduce it. |
| 1387 found = false; | 1407 found = false; |
| 1388 } else if ((intercepted & READ_ONLY) != 0) { | 1408 } else if ((intercepted & READ_ONLY) != 0) { |
| 1389 // The property is present, but read-only. Since we're trying to | 1409 // The property is present, but read-only, so we ignore the |
| 1390 // overwrite it with a variable declaration we must throw a | 1410 // redeclaration. However if we found readonly property |
| 1391 // re-declaration error. However if we found readonly property | |
| 1392 // on one of hidden prototypes, just shadow it. | 1411 // on one of hidden prototypes, just shadow it. |
| 1393 if (real_holder != isolate->context()->global()) break; | 1412 if (real_holder != isolate->context()->global()) break; |
| 1394 return ThrowRedeclarationError(isolate, "const", name); | 1413 return isolate->heap()->undefined_value(); |
| 1395 } | 1414 } |
| 1396 } | 1415 } |
| 1397 | 1416 |
| 1398 if (found && !assign) { | 1417 if (found && !assign) { |
| 1399 // The global property is there and we're not assigning any value | 1418 // The global property is there and we're not assigning any value |
| 1400 // to it. Just return. | 1419 // to it. Just return. |
| 1401 return isolate->heap()->undefined_value(); | 1420 return isolate->heap()->undefined_value(); |
| 1402 } | 1421 } |
| 1403 | 1422 |
| 1404 // Assign the value (or undefined) to the property. | 1423 // Assign the value (or undefined) to the property. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 index, | 1670 index, |
| 1652 last_match_info); | 1671 last_match_info); |
| 1653 if (result.is_null()) return Failure::Exception(); | 1672 if (result.is_null()) return Failure::Exception(); |
| 1654 return *result; | 1673 return *result; |
| 1655 } | 1674 } |
| 1656 | 1675 |
| 1657 | 1676 |
| 1658 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { | 1677 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { |
| 1659 ASSERT(args.length() == 3); | 1678 ASSERT(args.length() == 3); |
| 1660 CONVERT_SMI_ARG_CHECKED(elements_count, 0); | 1679 CONVERT_SMI_ARG_CHECKED(elements_count, 0); |
| 1661 if (elements_count > JSArray::kMaxFastElementsLength) { | 1680 if (elements_count < 0 || |
| 1681 elements_count > FixedArray::kMaxLength || |
| 1682 !Smi::IsValid(elements_count)) { |
| 1662 return isolate->ThrowIllegalOperation(); | 1683 return isolate->ThrowIllegalOperation(); |
| 1663 } | 1684 } |
| 1664 Object* new_object; | 1685 Object* new_object; |
| 1665 { MaybeObject* maybe_new_object = | 1686 { MaybeObject* maybe_new_object = |
| 1666 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); | 1687 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); |
| 1667 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 1688 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| 1668 } | 1689 } |
| 1669 FixedArray* elements = FixedArray::cast(new_object); | 1690 FixedArray* elements = FixedArray::cast(new_object); |
| 1670 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( | 1691 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( |
| 1671 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); | 1692 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 ASSERT(fun->should_have_prototype()); | 1974 ASSERT(fun->should_have_prototype()); |
| 1954 Object* obj; | 1975 Object* obj; |
| 1955 { MaybeObject* maybe_obj = | 1976 { MaybeObject* maybe_obj = |
| 1956 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 1977 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
| 1957 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1978 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1958 } | 1979 } |
| 1959 return args[0]; // return TOS | 1980 return args[0]; // return TOS |
| 1960 } | 1981 } |
| 1961 | 1982 |
| 1962 | 1983 |
| 1984 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
| 1985 NoHandleAllocation ha; |
| 1986 RUNTIME_ASSERT(args.length() == 1); |
| 1987 CONVERT_CHECKED(JSFunction, function, args[0]); |
| 1988 |
| 1989 MaybeObject* maybe_name = |
| 1990 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); |
| 1991 String* name; |
| 1992 if (!maybe_name->To(&name)) return maybe_name; |
| 1993 |
| 1994 if (function->HasFastProperties()) { |
| 1995 // Construct a new field descriptor with updated attributes. |
| 1996 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
| 1997 int index = instance_desc->Search(name); |
| 1998 ASSERT(index != DescriptorArray::kNotFound); |
| 1999 PropertyDetails details(instance_desc->GetDetails(index)); |
| 2000 CallbacksDescriptor new_desc(name, |
| 2001 instance_desc->GetValue(index), |
| 2002 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
| 2003 details.index()); |
| 2004 // Construct a new field descriptors array containing the new descriptor. |
| 2005 Object* descriptors_unchecked; |
| 2006 { MaybeObject* maybe_descriptors_unchecked = |
| 2007 instance_desc->CopyInsert(&new_desc, REMOVE_TRANSITIONS); |
| 2008 if (!maybe_descriptors_unchecked->ToObject(&descriptors_unchecked)) { |
| 2009 return maybe_descriptors_unchecked; |
| 2010 } |
| 2011 } |
| 2012 DescriptorArray* new_descriptors = |
| 2013 DescriptorArray::cast(descriptors_unchecked); |
| 2014 // Create a new map featuring the new field descriptors array. |
| 2015 Object* map_unchecked; |
| 2016 { MaybeObject* maybe_map_unchecked = function->map()->CopyDropDescriptors(); |
| 2017 if (!maybe_map_unchecked->ToObject(&map_unchecked)) { |
| 2018 return maybe_map_unchecked; |
| 2019 } |
| 2020 } |
| 2021 Map* new_map = Map::cast(map_unchecked); |
| 2022 new_map->set_instance_descriptors(new_descriptors); |
| 2023 function->set_map(new_map); |
| 2024 } else { // Dictionary properties. |
| 2025 // Directly manipulate the property details. |
| 2026 int entry = function->property_dictionary()->FindEntry(name); |
| 2027 ASSERT(entry != StringDictionary::kNotFound); |
| 2028 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); |
| 2029 PropertyDetails new_details( |
| 2030 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
| 2031 details.type(), |
| 2032 details.index()); |
| 2033 function->property_dictionary()->DetailsAtPut(entry, new_details); |
| 2034 } |
| 2035 return function; |
| 2036 } |
| 2037 |
| 2038 |
| 1963 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2039 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
| 1964 NoHandleAllocation ha; | 2040 NoHandleAllocation ha; |
| 1965 ASSERT(args.length() == 1); | 2041 ASSERT(args.length() == 1); |
| 1966 | 2042 |
| 1967 CONVERT_CHECKED(JSFunction, f, args[0]); | 2043 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1968 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() | 2044 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() |
| 1969 : isolate->heap()->false_value(); | 2045 : isolate->heap()->false_value(); |
| 1970 } | 2046 } |
| 1971 | 2047 |
| 1972 | 2048 |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3868 | 3944 |
| 3869 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 3945 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
| 3870 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION | 3946 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION |
| 3871 // delete it to avoid running into trouble in DefineAccessor, which | 3947 // delete it to avoid running into trouble in DefineAccessor, which |
| 3872 // handles this incorrectly if the property is readonly (does nothing) | 3948 // handles this incorrectly if the property is readonly (does nothing) |
| 3873 if (result.IsProperty() && | 3949 if (result.IsProperty() && |
| 3874 (result.type() == FIELD || result.type() == NORMAL | 3950 (result.type() == FIELD || result.type() == NORMAL |
| 3875 || result.type() == CONSTANT_FUNCTION)) { | 3951 || result.type() == CONSTANT_FUNCTION)) { |
| 3876 Object* ok; | 3952 Object* ok; |
| 3877 { MaybeObject* maybe_ok = | 3953 { MaybeObject* maybe_ok = |
| 3878 obj->DeleteProperty(name, JSObject::NORMAL_DELETION); | 3954 obj->DeleteProperty(name, JSReceiver::NORMAL_DELETION); |
| 3879 if (!maybe_ok->ToObject(&ok)) return maybe_ok; | 3955 if (!maybe_ok->ToObject(&ok)) return maybe_ok; |
| 3880 } | 3956 } |
| 3881 } | 3957 } |
| 3882 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); | 3958 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); |
| 3883 } | 3959 } |
| 3884 | 3960 |
| 3885 // Implements part of 8.12.9 DefineOwnProperty. | 3961 // Implements part of 8.12.9 DefineOwnProperty. |
| 3886 // There are 3 cases that lead here: | 3962 // There are 3 cases that lead here: |
| 3887 // Step 4a - define a new data property. | 3963 // Step 4a - define a new data property. |
| 3888 // Steps 9b & 12 - replace an existing accessor property with a data property. | 3964 // Steps 9b & 12 - replace an existing accessor property with a data property. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4122 | 4198 |
| 4123 if (name->AsArrayIndex(&index)) { | 4199 if (name->AsArrayIndex(&index)) { |
| 4124 return js_object->SetElement(index, *value, kNonStrictMode, true); | 4200 return js_object->SetElement(index, *value, kNonStrictMode, true); |
| 4125 } else { | 4201 } else { |
| 4126 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); | 4202 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); |
| 4127 } | 4203 } |
| 4128 } | 4204 } |
| 4129 | 4205 |
| 4130 | 4206 |
| 4131 MaybeObject* Runtime::ForceDeleteObjectProperty(Isolate* isolate, | 4207 MaybeObject* Runtime::ForceDeleteObjectProperty(Isolate* isolate, |
| 4132 Handle<JSObject> js_object, | 4208 Handle<JSReceiver> receiver, |
| 4133 Handle<Object> key) { | 4209 Handle<Object> key) { |
| 4134 HandleScope scope(isolate); | 4210 HandleScope scope(isolate); |
| 4135 | 4211 |
| 4136 // Check if the given key is an array index. | 4212 // Check if the given key is an array index. |
| 4137 uint32_t index; | 4213 uint32_t index; |
| 4138 if (key->ToArrayIndex(&index)) { | 4214 if (receiver->IsJSObject() && key->ToArrayIndex(&index)) { |
| 4139 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 4215 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
| 4140 // characters of a string using [] notation. In the case of a | 4216 // characters of a string using [] notation. In the case of a |
| 4141 // String object we just need to redirect the deletion to the | 4217 // String object we just need to redirect the deletion to the |
| 4142 // underlying string if the index is in range. Since the | 4218 // underlying string if the index is in range. Since the |
| 4143 // underlying string does nothing with the deletion, we can ignore | 4219 // underlying string does nothing with the deletion, we can ignore |
| 4144 // such deletions. | 4220 // such deletions. |
| 4145 if (js_object->IsStringObjectWithCharacterAt(index)) { | 4221 if (receiver->IsStringObjectWithCharacterAt(index)) { |
| 4146 return isolate->heap()->true_value(); | 4222 return isolate->heap()->true_value(); |
| 4147 } | 4223 } |
| 4148 | 4224 |
| 4149 return js_object->DeleteElement(index, JSObject::FORCE_DELETION); | 4225 return JSObject::cast(*receiver)->DeleteElement( |
| 4226 index, JSReceiver::FORCE_DELETION); |
| 4150 } | 4227 } |
| 4151 | 4228 |
| 4152 Handle<String> key_string; | 4229 Handle<String> key_string; |
| 4153 if (key->IsString()) { | 4230 if (key->IsString()) { |
| 4154 key_string = Handle<String>::cast(key); | 4231 key_string = Handle<String>::cast(key); |
| 4155 } else { | 4232 } else { |
| 4156 // Call-back into JavaScript to convert the key to a string. | 4233 // Call-back into JavaScript to convert the key to a string. |
| 4157 bool has_pending_exception = false; | 4234 bool has_pending_exception = false; |
| 4158 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 4235 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
| 4159 if (has_pending_exception) return Failure::Exception(); | 4236 if (has_pending_exception) return Failure::Exception(); |
| 4160 key_string = Handle<String>::cast(converted); | 4237 key_string = Handle<String>::cast(converted); |
| 4161 } | 4238 } |
| 4162 | 4239 |
| 4163 key_string->TryFlatten(); | 4240 key_string->TryFlatten(); |
| 4164 return js_object->DeleteProperty(*key_string, JSObject::FORCE_DELETION); | 4241 return receiver->DeleteProperty(*key_string, JSReceiver::FORCE_DELETION); |
| 4165 } | 4242 } |
| 4166 | 4243 |
| 4167 | 4244 |
| 4168 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 4245 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
| 4169 NoHandleAllocation ha; | 4246 NoHandleAllocation ha; |
| 4170 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 4247 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
| 4171 | 4248 |
| 4172 Handle<Object> object = args.at<Object>(0); | 4249 Handle<Object> object = args.at<Object>(0); |
| 4173 Handle<Object> key = args.at<Object>(1); | 4250 Handle<Object> key = args.at<Object>(1); |
| 4174 Handle<Object> value = args.at<Object>(2); | 4251 Handle<Object> value = args.at<Object>(2); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4233 | 4310 |
| 4234 return object-> | 4311 return object-> |
| 4235 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4312 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
| 4236 } | 4313 } |
| 4237 | 4314 |
| 4238 | 4315 |
| 4239 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 4316 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
| 4240 NoHandleAllocation ha; | 4317 NoHandleAllocation ha; |
| 4241 ASSERT(args.length() == 3); | 4318 ASSERT(args.length() == 3); |
| 4242 | 4319 |
| 4243 CONVERT_CHECKED(JSObject, object, args[0]); | 4320 CONVERT_CHECKED(JSReceiver, object, args[0]); |
| 4244 CONVERT_CHECKED(String, key, args[1]); | 4321 CONVERT_CHECKED(String, key, args[1]); |
| 4245 CONVERT_SMI_ARG_CHECKED(strict, 2); | 4322 CONVERT_SMI_ARG_CHECKED(strict, 2); |
| 4246 return object->DeleteProperty(key, (strict == kStrictMode) | 4323 return object->DeleteProperty(key, (strict == kStrictMode) |
| 4247 ? JSObject::STRICT_DELETION | 4324 ? JSReceiver::STRICT_DELETION |
| 4248 : JSObject::NORMAL_DELETION); | 4325 : JSReceiver::NORMAL_DELETION); |
| 4249 } | 4326 } |
| 4250 | 4327 |
| 4251 | 4328 |
| 4252 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4329 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
| 4253 Handle<JSObject> object, | 4330 Handle<JSObject> object, |
| 4254 Handle<String> key) { | 4331 Handle<String> key) { |
| 4255 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4332 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
| 4256 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4333 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 4257 // then we have to check it for properties, because they are supposed to | 4334 // then we have to check it for properties, because they are supposed to |
| 4258 // look like they are on this object. | 4335 // look like they are on this object. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4302 } | 4379 } |
| 4303 } | 4380 } |
| 4304 return isolate->heap()->false_value(); | 4381 return isolate->heap()->false_value(); |
| 4305 } | 4382 } |
| 4306 | 4383 |
| 4307 | 4384 |
| 4308 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 4385 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
| 4309 NoHandleAllocation na; | 4386 NoHandleAllocation na; |
| 4310 ASSERT(args.length() == 2); | 4387 ASSERT(args.length() == 2); |
| 4311 | 4388 |
| 4312 // Only JS objects can have properties. | 4389 // Only JS receivers can have properties. |
| 4313 if (args[0]->IsJSObject()) { | 4390 if (args[0]->IsJSReceiver()) { |
| 4314 JSObject* object = JSObject::cast(args[0]); | 4391 JSReceiver* receiver = JSReceiver::cast(args[0]); |
| 4315 CONVERT_CHECKED(String, key, args[1]); | 4392 CONVERT_CHECKED(String, key, args[1]); |
| 4316 if (object->HasProperty(key)) return isolate->heap()->true_value(); | 4393 if (receiver->HasProperty(key)) return isolate->heap()->true_value(); |
| 4317 } | 4394 } |
| 4318 return isolate->heap()->false_value(); | 4395 return isolate->heap()->false_value(); |
| 4319 } | 4396 } |
| 4320 | 4397 |
| 4321 | 4398 |
| 4322 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 4399 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
| 4323 NoHandleAllocation na; | 4400 NoHandleAllocation na; |
| 4324 ASSERT(args.length() == 2); | 4401 ASSERT(args.length() == 2); |
| 4325 | 4402 |
| 4326 // Only JS objects can have elements. | 4403 // Only JS objects can have elements. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4450 // Allocate an array with storage for all the property names. | 4527 // Allocate an array with storage for all the property names. |
| 4451 Handle<FixedArray> names = | 4528 Handle<FixedArray> names = |
| 4452 isolate->factory()->NewFixedArray(total_property_count); | 4529 isolate->factory()->NewFixedArray(total_property_count); |
| 4453 | 4530 |
| 4454 // Get the property names. | 4531 // Get the property names. |
| 4455 jsproto = obj; | 4532 jsproto = obj; |
| 4456 int proto_with_hidden_properties = 0; | 4533 int proto_with_hidden_properties = 0; |
| 4457 for (int i = 0; i < length; i++) { | 4534 for (int i = 0; i < length; i++) { |
| 4458 jsproto->GetLocalPropertyNames(*names, | 4535 jsproto->GetLocalPropertyNames(*names, |
| 4459 i == 0 ? 0 : local_property_count[i - 1]); | 4536 i == 0 ? 0 : local_property_count[i - 1]); |
| 4460 if (!GetHiddenProperties(jsproto, false)->IsUndefined()) { | 4537 if (jsproto->HasHiddenProperties()) { |
| 4461 proto_with_hidden_properties++; | 4538 proto_with_hidden_properties++; |
| 4462 } | 4539 } |
| 4463 if (i < length - 1) { | 4540 if (i < length - 1) { |
| 4464 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 4541 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 4465 } | 4542 } |
| 4466 } | 4543 } |
| 4467 | 4544 |
| 4468 // Filter out name of hidden propeties object. | 4545 // Filter out name of hidden propeties object. |
| 4469 if (proto_with_hidden_properties > 0) { | 4546 if (proto_with_hidden_properties > 0) { |
| 4470 Handle<FixedArray> old_names = names; | 4547 Handle<FixedArray> old_names = names; |
| (...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8194 | 8271 |
| 8195 // The slot was found in a JSObject, either a context extension object, | 8272 // The slot was found in a JSObject, either a context extension object, |
| 8196 // the global object, or an arguments object. Try to delete it | 8273 // the global object, or an arguments object. Try to delete it |
| 8197 // (respecting DONT_DELETE). For consistency with V8's usual behavior, | 8274 // (respecting DONT_DELETE). For consistency with V8's usual behavior, |
| 8198 // which allows deleting all parameters in functions that mention | 8275 // which allows deleting all parameters in functions that mention |
| 8199 // 'arguments', we do this even for the case of slots found on an | 8276 // 'arguments', we do this even for the case of slots found on an |
| 8200 // arguments object. The slot was found on an arguments object if the | 8277 // arguments object. The slot was found on an arguments object if the |
| 8201 // index is non-negative. | 8278 // index is non-negative. |
| 8202 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 8279 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
| 8203 if (index >= 0) { | 8280 if (index >= 0) { |
| 8204 return object->DeleteElement(index, JSObject::NORMAL_DELETION); | 8281 return object->DeleteElement(index, JSReceiver::NORMAL_DELETION); |
| 8205 } else { | 8282 } else { |
| 8206 return object->DeleteProperty(*name, JSObject::NORMAL_DELETION); | 8283 return object->DeleteProperty(*name, JSReceiver::NORMAL_DELETION); |
| 8207 } | 8284 } |
| 8208 } | 8285 } |
| 8209 | 8286 |
| 8210 | 8287 |
| 8211 // A mechanism to return a pair of Object pointers in registers (if possible). | 8288 // A mechanism to return a pair of Object pointers in registers (if possible). |
| 8212 // How this is achieved is calling convention-dependent. | 8289 // How this is achieved is calling convention-dependent. |
| 8213 // All currently supported x86 compiles uses calling conventions that are cdecl | 8290 // All currently supported x86 compiles uses calling conventions that are cdecl |
| 8214 // variants where a 64-bit value is returned in two 32-bit registers | 8291 // variants where a 64-bit value is returned in two 32-bit registers |
| 8215 // (edx:eax on ia32, r1:r0 on ARM). | 8292 // (edx:eax on ia32, r1:r0 on ARM). |
| 8216 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. | 8293 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9508 // Move contents of argument 0 (an array) to argument 1 (an array) | 9585 // Move contents of argument 0 (an array) to argument 1 (an array) |
| 9509 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 9586 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
| 9510 ASSERT(args.length() == 2); | 9587 ASSERT(args.length() == 2); |
| 9511 CONVERT_CHECKED(JSArray, from, args[0]); | 9588 CONVERT_CHECKED(JSArray, from, args[0]); |
| 9512 CONVERT_CHECKED(JSArray, to, args[1]); | 9589 CONVERT_CHECKED(JSArray, to, args[1]); |
| 9513 HeapObject* new_elements = from->elements(); | 9590 HeapObject* new_elements = from->elements(); |
| 9514 MaybeObject* maybe_new_map; | 9591 MaybeObject* maybe_new_map; |
| 9515 if (new_elements->map() == isolate->heap()->fixed_array_map() || | 9592 if (new_elements->map() == isolate->heap()->fixed_array_map() || |
| 9516 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 9593 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { |
| 9517 maybe_new_map = to->map()->GetFastElementsMap(); | 9594 maybe_new_map = to->map()->GetFastElementsMap(); |
| 9595 } else if (new_elements->map() == |
| 9596 isolate->heap()->fixed_double_array_map()) { |
| 9597 maybe_new_map = to->map()->GetFastDoubleElementsMap(); |
| 9518 } else { | 9598 } else { |
| 9519 maybe_new_map = to->map()->GetSlowElementsMap(); | 9599 maybe_new_map = to->map()->GetSlowElementsMap(); |
| 9520 } | 9600 } |
| 9521 Object* new_map; | 9601 Object* new_map; |
| 9522 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 9602 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
| 9523 to->set_map(Map::cast(new_map)); | 9603 to->set_map(Map::cast(new_map)); |
| 9524 to->set_elements(new_elements); | 9604 to->set_elements(new_elements); |
| 9525 to->set_length(from->length()); | 9605 to->set_length(from->length()); |
| 9526 Object* obj; | 9606 Object* obj; |
| 9527 { MaybeObject* maybe_obj = from->ResetElements(); | 9607 { MaybeObject* maybe_obj = from->ResetElements(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9595 for (int i = 0; i < keys_length; i++) { | 9675 for (int i = 0; i < keys_length; i++) { |
| 9596 Object* key = keys->get(i); | 9676 Object* key = keys->get(i); |
| 9597 uint32_t index = 0; | 9677 uint32_t index = 0; |
| 9598 if (!key->ToArrayIndex(&index) || index >= length) { | 9678 if (!key->ToArrayIndex(&index) || index >= length) { |
| 9599 // Zap invalid keys. | 9679 // Zap invalid keys. |
| 9600 keys->set_undefined(i); | 9680 keys->set_undefined(i); |
| 9601 } | 9681 } |
| 9602 } | 9682 } |
| 9603 return *isolate->factory()->NewJSArrayWithElements(keys); | 9683 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 9604 } else { | 9684 } else { |
| 9605 ASSERT(array->HasFastElements()); | 9685 ASSERT(array->HasFastElements() || array->HasFastDoubleElements()); |
| 9606 Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2); | 9686 Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2); |
| 9607 // -1 means start of array. | 9687 // -1 means start of array. |
| 9608 single_interval->set(0, Smi::FromInt(-1)); | 9688 single_interval->set(0, Smi::FromInt(-1)); |
| 9689 FixedArrayBase* elements = FixedArrayBase::cast(array->elements()); |
| 9609 uint32_t actual_length = | 9690 uint32_t actual_length = |
| 9610 static_cast<uint32_t>(FixedArray::cast(array->elements())->length()); | 9691 static_cast<uint32_t>(elements->length()); |
| 9611 uint32_t min_length = actual_length < length ? actual_length : length; | 9692 uint32_t min_length = actual_length < length ? actual_length : length; |
| 9612 Handle<Object> length_object = | 9693 Handle<Object> length_object = |
| 9613 isolate->factory()->NewNumber(static_cast<double>(min_length)); | 9694 isolate->factory()->NewNumber(static_cast<double>(min_length)); |
| 9614 single_interval->set(1, *length_object); | 9695 single_interval->set(1, *length_object); |
| 9615 return *isolate->factory()->NewJSArrayWithElements(single_interval); | 9696 return *isolate->factory()->NewJSArrayWithElements(single_interval); |
| 9616 } | 9697 } |
| 9617 } | 9698 } |
| 9618 | 9699 |
| 9619 | 9700 |
| 9620 // DefineAccessor takes an optional final argument which is the | 9701 // DefineAccessor takes an optional final argument which is the |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9972 return Smi::FromInt(0); | 10053 return Smi::FromInt(0); |
| 9973 } | 10054 } |
| 9974 | 10055 |
| 9975 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { | 10056 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { |
| 9976 n += it.frame()->GetInlineCount(); | 10057 n += it.frame()->GetInlineCount(); |
| 9977 } | 10058 } |
| 9978 return Smi::FromInt(n); | 10059 return Smi::FromInt(n); |
| 9979 } | 10060 } |
| 9980 | 10061 |
| 9981 | 10062 |
| 10063 class FrameInspector { |
| 10064 public: |
| 10065 FrameInspector(JavaScriptFrame* frame, |
| 10066 int inlined_frame_index, |
| 10067 Isolate* isolate) |
| 10068 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { |
| 10069 // Calculate the deoptimized frame. |
| 10070 if (frame->is_optimized()) { |
| 10071 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( |
| 10072 frame, inlined_frame_index, isolate); |
| 10073 } |
| 10074 has_adapted_arguments_ = frame_->has_adapted_arguments(); |
| 10075 is_optimized_ = frame_->is_optimized(); |
| 10076 } |
| 10077 |
| 10078 ~FrameInspector() { |
| 10079 // Get rid of the calculated deoptimized frame if any. |
| 10080 if (deoptimized_frame_ != NULL) { |
| 10081 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, |
| 10082 isolate_); |
| 10083 } |
| 10084 } |
| 10085 |
| 10086 int GetParametersCount() { |
| 10087 return is_optimized_ |
| 10088 ? deoptimized_frame_->parameters_count() |
| 10089 : frame_->ComputeParametersCount(); |
| 10090 } |
| 10091 int expression_count() { return deoptimized_frame_->expression_count(); } |
| 10092 Object* GetFunction() { |
| 10093 return is_optimized_ |
| 10094 ? deoptimized_frame_->GetFunction() |
| 10095 : frame_->function(); |
| 10096 } |
| 10097 Object* GetParameter(int index) { |
| 10098 return is_optimized_ |
| 10099 ? deoptimized_frame_->GetParameter(index) |
| 10100 : frame_->GetParameter(index); |
| 10101 } |
| 10102 Object* GetExpression(int index) { |
| 10103 return is_optimized_ |
| 10104 ? deoptimized_frame_->GetExpression(index) |
| 10105 : frame_->GetExpression(index); |
| 10106 } |
| 10107 |
| 10108 // To inspect all the provided arguments the frame might need to be |
| 10109 // replaced with the arguments frame. |
| 10110 void SetArgumentsFrame(JavaScriptFrame* frame) { |
| 10111 ASSERT(has_adapted_arguments_); |
| 10112 frame_ = frame; |
| 10113 is_optimized_ = frame_->is_optimized(); |
| 10114 ASSERT(!is_optimized_); |
| 10115 } |
| 10116 |
| 10117 private: |
| 10118 JavaScriptFrame* frame_; |
| 10119 DeoptimizedFrameInfo* deoptimized_frame_; |
| 10120 Isolate* isolate_; |
| 10121 bool is_optimized_; |
| 10122 bool has_adapted_arguments_; |
| 10123 |
| 10124 DISALLOW_COPY_AND_ASSIGN(FrameInspector); |
| 10125 }; |
| 10126 |
| 10127 |
| 9982 static const int kFrameDetailsFrameIdIndex = 0; | 10128 static const int kFrameDetailsFrameIdIndex = 0; |
| 9983 static const int kFrameDetailsReceiverIndex = 1; | 10129 static const int kFrameDetailsReceiverIndex = 1; |
| 9984 static const int kFrameDetailsFunctionIndex = 2; | 10130 static const int kFrameDetailsFunctionIndex = 2; |
| 9985 static const int kFrameDetailsArgumentCountIndex = 3; | 10131 static const int kFrameDetailsArgumentCountIndex = 3; |
| 9986 static const int kFrameDetailsLocalCountIndex = 4; | 10132 static const int kFrameDetailsLocalCountIndex = 4; |
| 9987 static const int kFrameDetailsSourcePositionIndex = 5; | 10133 static const int kFrameDetailsSourcePositionIndex = 5; |
| 9988 static const int kFrameDetailsConstructCallIndex = 6; | 10134 static const int kFrameDetailsConstructCallIndex = 6; |
| 9989 static const int kFrameDetailsAtReturnIndex = 7; | 10135 static const int kFrameDetailsAtReturnIndex = 7; |
| 9990 static const int kFrameDetailsFlagsIndex = 8; | 10136 static const int kFrameDetailsFlagsIndex = 8; |
| 9991 static const int kFrameDetailsFirstDynamicIndex = 9; | 10137 static const int kFrameDetailsFirstDynamicIndex = 9; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 10020 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 10166 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 10021 Heap* heap = isolate->heap(); | 10167 Heap* heap = isolate->heap(); |
| 10022 | 10168 |
| 10023 // Find the relevant frame with the requested index. | 10169 // Find the relevant frame with the requested index. |
| 10024 StackFrame::Id id = isolate->debug()->break_frame_id(); | 10170 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| 10025 if (id == StackFrame::NO_ID) { | 10171 if (id == StackFrame::NO_ID) { |
| 10026 // If there are no JavaScript stack frames return undefined. | 10172 // If there are no JavaScript stack frames return undefined. |
| 10027 return heap->undefined_value(); | 10173 return heap->undefined_value(); |
| 10028 } | 10174 } |
| 10029 | 10175 |
| 10030 int deoptimized_frame_index = -1; // Frame index in optimized frame. | 10176 int inlined_frame_index = 0; // Inlined frame index in optimized frame. |
| 10031 DeoptimizedFrameInfo* deoptimized_frame = NULL; | |
| 10032 | 10177 |
| 10033 int count = 0; | 10178 int count = 0; |
| 10034 JavaScriptFrameIterator it(isolate, id); | 10179 JavaScriptFrameIterator it(isolate, id); |
| 10035 for (; !it.done(); it.Advance()) { | 10180 for (; !it.done(); it.Advance()) { |
| 10036 if (index < count + it.frame()->GetInlineCount()) break; | 10181 if (index < count + it.frame()->GetInlineCount()) break; |
| 10037 count += it.frame()->GetInlineCount(); | 10182 count += it.frame()->GetInlineCount(); |
| 10038 } | 10183 } |
| 10039 if (it.done()) return heap->undefined_value(); | 10184 if (it.done()) return heap->undefined_value(); |
| 10040 | 10185 |
| 10041 if (it.frame()->is_optimized()) { | 10186 if (it.frame()->is_optimized()) { |
| 10042 deoptimized_frame_index = | 10187 inlined_frame_index = |
| 10043 it.frame()->GetInlineCount() - (index - count) - 1; | 10188 it.frame()->GetInlineCount() - (index - count) - 1; |
| 10044 deoptimized_frame = Deoptimizer::DebuggerInspectableFrame( | |
| 10045 it.frame(), | |
| 10046 deoptimized_frame_index, | |
| 10047 isolate); | |
| 10048 } | 10189 } |
| 10190 FrameInspector frame_inspector(it.frame(), inlined_frame_index, isolate); |
| 10049 | 10191 |
| 10050 // Traverse the saved contexts chain to find the active context for the | 10192 // Traverse the saved contexts chain to find the active context for the |
| 10051 // selected frame. | 10193 // selected frame. |
| 10052 SaveContext* save = isolate->save_context(); | 10194 SaveContext* save = isolate->save_context(); |
| 10053 while (save != NULL && !save->below(it.frame())) { | 10195 while (save != NULL && !save->below(it.frame())) { |
| 10054 save = save->prev(); | 10196 save = save->prev(); |
| 10055 } | 10197 } |
| 10056 ASSERT(save != NULL); | 10198 ASSERT(save != NULL); |
| 10057 | 10199 |
| 10058 // Get the frame id. | 10200 // Get the frame id. |
| 10059 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); | 10201 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); |
| 10060 | 10202 |
| 10061 // Find source position. | 10203 // Find source position. |
| 10062 int position = | 10204 int position = |
| 10063 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); | 10205 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); |
| 10064 | 10206 |
| 10065 // Check for constructor frame. Inlined frames cannot be construct calls. | 10207 // Check for constructor frame. Inlined frames cannot be construct calls. |
| 10066 bool inlined_frame = | 10208 bool inlined_frame = |
| 10067 it.frame()->is_optimized() && deoptimized_frame_index != 0; | 10209 it.frame()->is_optimized() && inlined_frame_index != 0; |
| 10068 bool constructor = !inlined_frame && it.frame()->IsConstructor(); | 10210 bool constructor = !inlined_frame && it.frame()->IsConstructor(); |
| 10069 | 10211 |
| 10070 // Get scope info and read from it for local variable information. | 10212 // Get scope info and read from it for local variable information. |
| 10071 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); | 10213 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); |
| 10072 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 10214 Handle<SharedFunctionInfo> shared(function->shared()); |
| 10215 Handle<SerializedScopeInfo> scope_info(shared->scope_info()); |
| 10073 ASSERT(*scope_info != SerializedScopeInfo::Empty()); | 10216 ASSERT(*scope_info != SerializedScopeInfo::Empty()); |
| 10074 ScopeInfo<> info(*scope_info); | 10217 ScopeInfo<> info(*scope_info); |
| 10075 | 10218 |
| 10076 // Get the locals names and values into a temporary array. | 10219 // Get the locals names and values into a temporary array. |
| 10077 // | 10220 // |
| 10078 // TODO(1240907): Hide compiler-introduced stack variables | 10221 // TODO(1240907): Hide compiler-introduced stack variables |
| 10079 // (e.g. .result)? For users of the debugger, they will probably be | 10222 // (e.g. .result)? For users of the debugger, they will probably be |
| 10080 // confusing. | 10223 // confusing. |
| 10081 Handle<FixedArray> locals = | 10224 Handle<FixedArray> locals = |
| 10082 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); | 10225 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); |
| 10083 | 10226 |
| 10084 // Fill in the values of the locals. | 10227 // Fill in the values of the locals. |
| 10085 int i = 0; | 10228 int i = 0; |
| 10086 for (; i < info.number_of_stack_slots(); ++i) { | 10229 for (; i < info.number_of_stack_slots(); ++i) { |
| 10087 // Use the value from the stack. | 10230 // Use the value from the stack. |
| 10088 locals->set(i * 2, *info.LocalName(i)); | 10231 locals->set(i * 2, *info.LocalName(i)); |
| 10089 if (it.frame()->is_optimized()) { | 10232 locals->set(i * 2 + 1, frame_inspector.GetExpression(i)); |
| 10090 // Get the value from the deoptimized frame. | |
| 10091 locals->set(i * 2 + 1, | |
| 10092 deoptimized_frame->GetExpression(i)); | |
| 10093 } else { | |
| 10094 // Get the value from the stack. | |
| 10095 locals->set(i * 2 + 1, it.frame()->GetExpression(i)); | |
| 10096 } | |
| 10097 } | 10233 } |
| 10098 if (i < info.NumberOfLocals()) { | 10234 if (i < info.NumberOfLocals()) { |
| 10099 // Get the context containing declarations. | 10235 // Get the context containing declarations. |
| 10100 Handle<Context> context( | 10236 Handle<Context> context( |
| 10101 Context::cast(it.frame()->context())->declaration_context()); | 10237 Context::cast(it.frame()->context())->declaration_context()); |
| 10102 for (; i < info.NumberOfLocals(); ++i) { | 10238 for (; i < info.NumberOfLocals(); ++i) { |
| 10103 Handle<String> name = info.LocalName(i); | 10239 Handle<String> name = info.LocalName(i); |
| 10104 locals->set(i * 2, *name); | 10240 locals->set(i * 2, *name); |
| 10105 locals->set(i * 2 + 1, | 10241 locals->set(i * 2 + 1, |
| 10106 context->get(scope_info->ContextSlotIndex(*name, NULL))); | 10242 context->get(scope_info->ContextSlotIndex(*name, NULL))); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10143 internal_frame_sp = NULL; | 10279 internal_frame_sp = NULL; |
| 10144 } | 10280 } |
| 10145 it2.Advance(); | 10281 it2.Advance(); |
| 10146 } | 10282 } |
| 10147 } | 10283 } |
| 10148 | 10284 |
| 10149 // Now advance to the arguments adapter frame (if any). It contains all | 10285 // Now advance to the arguments adapter frame (if any). It contains all |
| 10150 // the provided parameters whereas the function frame always have the number | 10286 // the provided parameters whereas the function frame always have the number |
| 10151 // of arguments matching the functions parameters. The rest of the | 10287 // of arguments matching the functions parameters. The rest of the |
| 10152 // information (except for what is collected above) is the same. | 10288 // information (except for what is collected above) is the same. |
| 10153 it.AdvanceToArgumentsFrame(); | 10289 if (it.frame()->has_adapted_arguments()) { |
| 10290 it.AdvanceToArgumentsFrame(); |
| 10291 frame_inspector.SetArgumentsFrame(it.frame()); |
| 10292 } |
| 10154 | 10293 |
| 10155 // Find the number of arguments to fill. At least fill the number of | 10294 // Find the number of arguments to fill. At least fill the number of |
| 10156 // parameters for the function and fill more if more parameters are provided. | 10295 // parameters for the function and fill more if more parameters are provided. |
| 10157 int argument_count = info.number_of_parameters(); | 10296 int argument_count = info.number_of_parameters(); |
| 10297 if (argument_count < frame_inspector.GetParametersCount()) { |
| 10298 argument_count = frame_inspector.GetParametersCount(); |
| 10299 } |
| 10300 #ifdef DEBUG |
| 10158 if (it.frame()->is_optimized()) { | 10301 if (it.frame()->is_optimized()) { |
| 10159 ASSERT_EQ(argument_count, deoptimized_frame->parameters_count()); | 10302 ASSERT_EQ(argument_count, frame_inspector.GetParametersCount()); |
| 10160 } else { | |
| 10161 if (argument_count < it.frame()->ComputeParametersCount()) { | |
| 10162 argument_count = it.frame()->ComputeParametersCount(); | |
| 10163 } | |
| 10164 } | 10303 } |
| 10304 #endif |
| 10165 | 10305 |
| 10166 // Calculate the size of the result. | 10306 // Calculate the size of the result. |
| 10167 int details_size = kFrameDetailsFirstDynamicIndex + | 10307 int details_size = kFrameDetailsFirstDynamicIndex + |
| 10168 2 * (argument_count + info.NumberOfLocals()) + | 10308 2 * (argument_count + info.NumberOfLocals()) + |
| 10169 (at_return ? 1 : 0); | 10309 (at_return ? 1 : 0); |
| 10170 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 10310 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
| 10171 | 10311 |
| 10172 // Add the frame id. | 10312 // Add the frame id. |
| 10173 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 10313 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
| 10174 | 10314 |
| 10175 // Add the function (same as in function frame). | 10315 // Add the function (same as in function frame). |
| 10176 if (it.frame()->is_optimized()) { | 10316 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); |
| 10177 // Get the function from the deoptimized frame. | |
| 10178 details->set(kFrameDetailsFunctionIndex, deoptimized_frame->GetFunction()); | |
| 10179 } else { | |
| 10180 // Get the function from the stack. | |
| 10181 details->set(kFrameDetailsFunctionIndex, it.frame()->function()); | |
| 10182 } | |
| 10183 | 10317 |
| 10184 // Add the arguments count. | 10318 // Add the arguments count. |
| 10185 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); | 10319 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); |
| 10186 | 10320 |
| 10187 // Add the locals count | 10321 // Add the locals count |
| 10188 details->set(kFrameDetailsLocalCountIndex, | 10322 details->set(kFrameDetailsLocalCountIndex, |
| 10189 Smi::FromInt(info.NumberOfLocals())); | 10323 Smi::FromInt(info.NumberOfLocals())); |
| 10190 | 10324 |
| 10191 // Add the source position. | 10325 // Add the source position. |
| 10192 if (position != RelocInfo::kNoPosition) { | 10326 if (position != RelocInfo::kNoPosition) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10204 // Add flags to indicate information on whether this frame is | 10338 // Add flags to indicate information on whether this frame is |
| 10205 // bit 0: invoked in the debugger context. | 10339 // bit 0: invoked in the debugger context. |
| 10206 // bit 1: optimized frame. | 10340 // bit 1: optimized frame. |
| 10207 // bit 2: inlined in optimized frame | 10341 // bit 2: inlined in optimized frame |
| 10208 int flags = 0; | 10342 int flags = 0; |
| 10209 if (*save->context() == *isolate->debug()->debug_context()) { | 10343 if (*save->context() == *isolate->debug()->debug_context()) { |
| 10210 flags |= 1 << 0; | 10344 flags |= 1 << 0; |
| 10211 } | 10345 } |
| 10212 if (it.frame()->is_optimized()) { | 10346 if (it.frame()->is_optimized()) { |
| 10213 flags |= 1 << 1; | 10347 flags |= 1 << 1; |
| 10214 if (deoptimized_frame_index > 0) { | 10348 flags |= inlined_frame_index << 2; |
| 10215 flags |= 1 << 2; | |
| 10216 } | |
| 10217 } | 10349 } |
| 10218 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); | 10350 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); |
| 10219 | 10351 |
| 10220 // Fill the dynamic part. | 10352 // Fill the dynamic part. |
| 10221 int details_index = kFrameDetailsFirstDynamicIndex; | 10353 int details_index = kFrameDetailsFirstDynamicIndex; |
| 10222 | 10354 |
| 10223 // Add arguments name and value. | 10355 // Add arguments name and value. |
| 10224 for (int i = 0; i < argument_count; i++) { | 10356 for (int i = 0; i < argument_count; i++) { |
| 10225 // Name of the argument. | 10357 // Name of the argument. |
| 10226 if (i < info.number_of_parameters()) { | 10358 if (i < info.number_of_parameters()) { |
| 10227 details->set(details_index++, *info.parameter_name(i)); | 10359 details->set(details_index++, *info.parameter_name(i)); |
| 10228 } else { | 10360 } else { |
| 10229 details->set(details_index++, heap->undefined_value()); | 10361 details->set(details_index++, heap->undefined_value()); |
| 10230 } | 10362 } |
| 10231 | 10363 |
| 10232 // Parameter value. | 10364 // Parameter value. |
| 10233 if (it.frame()->is_optimized()) { | 10365 if (i < it.frame()->ComputeParametersCount()) { |
| 10234 // Get the value from the deoptimized frame. | 10366 // Get the value from the stack. |
| 10235 details->set(details_index++, deoptimized_frame->GetParameter(i)); | 10367 details->set(details_index++, frame_inspector.GetParameter(i)); |
| 10236 } else { | 10368 } else { |
| 10237 if (i < it.frame()->ComputeParametersCount()) { | 10369 details->set(details_index++, heap->undefined_value()); |
| 10238 // Get the value from the stack. | |
| 10239 details->set(details_index++, it.frame()->GetParameter(i)); | |
| 10240 } else { | |
| 10241 details->set(details_index++, heap->undefined_value()); | |
| 10242 } | |
| 10243 } | 10370 } |
| 10244 } | 10371 } |
| 10245 | 10372 |
| 10246 // Add locals name and value from the temporary copy from the function frame. | 10373 // Add locals name and value from the temporary copy from the function frame. |
| 10247 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { | 10374 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { |
| 10248 details->set(details_index++, locals->get(i)); | 10375 details->set(details_index++, locals->get(i)); |
| 10249 } | 10376 } |
| 10250 | 10377 |
| 10251 // Add the value being returned. | 10378 // Add the value being returned. |
| 10252 if (at_return) { | 10379 if (at_return) { |
| 10253 details->set(details_index++, *return_value); | 10380 details->set(details_index++, *return_value); |
| 10254 } | 10381 } |
| 10255 | 10382 |
| 10256 // Add the receiver (same as in function frame). | 10383 // Add the receiver (same as in function frame). |
| 10257 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | 10384 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
| 10258 // THE FRAME ITERATOR TO WRAP THE RECEIVER. | 10385 // THE FRAME ITERATOR TO WRAP THE RECEIVER. |
| 10259 Handle<Object> receiver(it.frame()->receiver(), isolate); | 10386 Handle<Object> receiver(it.frame()->receiver(), isolate); |
| 10260 if (!receiver->IsJSObject()) { | 10387 if (!receiver->IsJSObject() && !shared->strict_mode() && !shared->native()) { |
| 10261 // If the receiver is NOT a JSObject we have hit an optimization | 10388 // If the receiver is not a JSObject and the function is not a |
| 10262 // where a value object is not converted into a wrapped JS objects. | 10389 // builtin or strict-mode we have hit an optimization where a |
| 10263 // To hide this optimization from the debugger, we wrap the receiver | 10390 // value object is not converted into a wrapped JS objects. To |
| 10391 // hide this optimization from the debugger, we wrap the receiver |
| 10264 // by creating correct wrapper object based on the calling frame's | 10392 // by creating correct wrapper object based on the calling frame's |
| 10265 // global context. | 10393 // global context. |
| 10266 it.Advance(); | 10394 it.Advance(); |
| 10267 Handle<Context> calling_frames_global_context( | 10395 Handle<Context> calling_frames_global_context( |
| 10268 Context::cast(Context::cast(it.frame()->context())->global_context())); | 10396 Context::cast(Context::cast(it.frame()->context())->global_context())); |
| 10269 receiver = | 10397 receiver = |
| 10270 isolate->factory()->ToObject(receiver, calling_frames_global_context); | 10398 isolate->factory()->ToObject(receiver, calling_frames_global_context); |
| 10271 } | 10399 } |
| 10272 details->set(kFrameDetailsReceiverIndex, *receiver); | 10400 details->set(kFrameDetailsReceiverIndex, *receiver); |
| 10273 | 10401 |
| 10274 // Get rid of the calculated deoptimized frame if any. | |
| 10275 if (deoptimized_frame != NULL) { | |
| 10276 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame, | |
| 10277 isolate); | |
| 10278 } | |
| 10279 | |
| 10280 ASSERT_EQ(details_size, details_index); | 10402 ASSERT_EQ(details_size, details_index); |
| 10281 return *isolate->factory()->NewJSArrayWithElements(details); | 10403 return *isolate->factory()->NewJSArrayWithElements(details); |
| 10282 } | 10404 } |
| 10283 | 10405 |
| 10284 | 10406 |
| 10285 // Copy all the context locals into an object used to materialize a scope. | 10407 // Copy all the context locals into an object used to materialize a scope. |
| 10286 static bool CopyContextLocalsToScopeObject( | 10408 static bool CopyContextLocalsToScopeObject( |
| 10287 Isolate* isolate, | 10409 Isolate* isolate, |
| 10288 Handle<SerializedScopeInfo> serialized_scope_info, | 10410 Handle<SerializedScopeInfo> serialized_scope_info, |
| 10289 ScopeInfo<>& scope_info, | 10411 ScopeInfo<>& scope_info, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 10305 kNonStrictMode), | 10427 kNonStrictMode), |
| 10306 false); | 10428 false); |
| 10307 } | 10429 } |
| 10308 | 10430 |
| 10309 return true; | 10431 return true; |
| 10310 } | 10432 } |
| 10311 | 10433 |
| 10312 | 10434 |
| 10313 // Create a plain JSObject which materializes the local scope for the specified | 10435 // Create a plain JSObject which materializes the local scope for the specified |
| 10314 // frame. | 10436 // frame. |
| 10315 static Handle<JSObject> MaterializeLocalScope(Isolate* isolate, | 10437 static Handle<JSObject> MaterializeLocalScope( |
| 10316 JavaScriptFrame* frame) { | 10438 Isolate* isolate, |
| 10439 JavaScriptFrame* frame, |
| 10440 int inlined_frame_index) { |
| 10317 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 10441 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| 10318 Handle<SharedFunctionInfo> shared(function->shared()); | 10442 Handle<SharedFunctionInfo> shared(function->shared()); |
| 10319 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 10443 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); |
| 10320 ScopeInfo<> scope_info(*serialized_scope_info); | 10444 ScopeInfo<> scope_info(*serialized_scope_info); |
| 10445 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
| 10321 | 10446 |
| 10322 // Allocate and initialize a JSObject with all the arguments, stack locals | 10447 // Allocate and initialize a JSObject with all the arguments, stack locals |
| 10323 // heap locals and extension properties of the debugged function. | 10448 // heap locals and extension properties of the debugged function. |
| 10324 Handle<JSObject> local_scope = | 10449 Handle<JSObject> local_scope = |
| 10325 isolate->factory()->NewJSObject(isolate->object_function()); | 10450 isolate->factory()->NewJSObject(isolate->object_function()); |
| 10326 | 10451 |
| 10327 // First fill all parameters. | 10452 // First fill all parameters. |
| 10328 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | 10453 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { |
| 10329 RETURN_IF_EMPTY_HANDLE_VALUE( | 10454 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 10330 isolate, | 10455 isolate, |
| 10331 SetProperty(local_scope, | 10456 SetProperty(local_scope, |
| 10332 scope_info.parameter_name(i), | 10457 scope_info.parameter_name(i), |
| 10333 Handle<Object>(frame->GetParameter(i), isolate), | 10458 Handle<Object>(frame_inspector.GetParameter(i)), |
| 10334 NONE, | 10459 NONE, |
| 10335 kNonStrictMode), | 10460 kNonStrictMode), |
| 10336 Handle<JSObject>()); | 10461 Handle<JSObject>()); |
| 10337 } | 10462 } |
| 10338 | 10463 |
| 10339 // Second fill all stack locals. | 10464 // Second fill all stack locals. |
| 10340 for (int i = 0; i < scope_info.number_of_stack_slots(); ++i) { | 10465 for (int i = 0; i < scope_info.number_of_stack_slots(); ++i) { |
| 10341 RETURN_IF_EMPTY_HANDLE_VALUE( | 10466 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 10342 isolate, | 10467 isolate, |
| 10343 SetProperty(local_scope, | 10468 SetProperty(local_scope, |
| 10344 scope_info.stack_slot_name(i), | 10469 scope_info.stack_slot_name(i), |
| 10345 Handle<Object>(frame->GetExpression(i), isolate), | 10470 Handle<Object>(frame_inspector.GetExpression(i)), |
| 10346 NONE, | 10471 NONE, |
| 10347 kNonStrictMode), | 10472 kNonStrictMode), |
| 10348 Handle<JSObject>()); | 10473 Handle<JSObject>()); |
| 10349 } | 10474 } |
| 10350 | 10475 |
| 10351 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 10476 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { |
| 10352 // Third fill all context locals. | 10477 // Third fill all context locals. |
| 10353 Handle<Context> frame_context(Context::cast(frame->context())); | 10478 Handle<Context> frame_context(Context::cast(frame->context())); |
| 10354 Handle<Context> function_context(frame_context->declaration_context()); | 10479 Handle<Context> function_context(frame_context->declaration_context()); |
| 10355 if (!CopyContextLocalsToScopeObject(isolate, | 10480 if (!CopyContextLocalsToScopeObject(isolate, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10455 class ScopeIterator { | 10580 class ScopeIterator { |
| 10456 public: | 10581 public: |
| 10457 enum ScopeType { | 10582 enum ScopeType { |
| 10458 ScopeTypeGlobal = 0, | 10583 ScopeTypeGlobal = 0, |
| 10459 ScopeTypeLocal, | 10584 ScopeTypeLocal, |
| 10460 ScopeTypeWith, | 10585 ScopeTypeWith, |
| 10461 ScopeTypeClosure, | 10586 ScopeTypeClosure, |
| 10462 ScopeTypeCatch | 10587 ScopeTypeCatch |
| 10463 }; | 10588 }; |
| 10464 | 10589 |
| 10465 ScopeIterator(Isolate* isolate, JavaScriptFrame* frame) | 10590 ScopeIterator(Isolate* isolate, |
| 10591 JavaScriptFrame* frame, |
| 10592 int inlined_frame_index) |
| 10466 : isolate_(isolate), | 10593 : isolate_(isolate), |
| 10467 frame_(frame), | 10594 frame_(frame), |
| 10595 inlined_frame_index_(inlined_frame_index), |
| 10468 function_(JSFunction::cast(frame->function())), | 10596 function_(JSFunction::cast(frame->function())), |
| 10469 context_(Context::cast(frame->context())), | 10597 context_(Context::cast(frame->context())), |
| 10470 local_done_(false), | 10598 local_done_(false), |
| 10471 at_local_(false) { | 10599 at_local_(false) { |
| 10472 | 10600 |
| 10473 // Check whether the first scope is actually a local scope. | 10601 // Check whether the first scope is actually a local scope. |
| 10474 if (context_->IsGlobalContext()) { | 10602 if (context_->IsGlobalContext()) { |
| 10475 // If there is a stack slot for .result then this local scope has been | 10603 // If there is a stack slot for .result then this local scope has been |
| 10476 // created for evaluating top level code and it is not a real local scope. | 10604 // created for evaluating top level code and it is not a real local scope. |
| 10477 // Checking for the existence of .result seems fragile, but the scope info | 10605 // Checking for the existence of .result seems fragile, but the scope info |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10542 return ScopeTypeWith; | 10670 return ScopeTypeWith; |
| 10543 } | 10671 } |
| 10544 | 10672 |
| 10545 // Return the JavaScript object with the content of the current scope. | 10673 // Return the JavaScript object with the content of the current scope. |
| 10546 Handle<JSObject> ScopeObject() { | 10674 Handle<JSObject> ScopeObject() { |
| 10547 switch (Type()) { | 10675 switch (Type()) { |
| 10548 case ScopeIterator::ScopeTypeGlobal: | 10676 case ScopeIterator::ScopeTypeGlobal: |
| 10549 return Handle<JSObject>(CurrentContext()->global()); | 10677 return Handle<JSObject>(CurrentContext()->global()); |
| 10550 case ScopeIterator::ScopeTypeLocal: | 10678 case ScopeIterator::ScopeTypeLocal: |
| 10551 // Materialize the content of the local scope into a JSObject. | 10679 // Materialize the content of the local scope into a JSObject. |
| 10552 return MaterializeLocalScope(isolate_, frame_); | 10680 return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_); |
| 10553 case ScopeIterator::ScopeTypeWith: | 10681 case ScopeIterator::ScopeTypeWith: |
| 10554 // Return the with object. | 10682 // Return the with object. |
| 10555 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 10683 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
| 10556 case ScopeIterator::ScopeTypeCatch: | 10684 case ScopeIterator::ScopeTypeCatch: |
| 10557 return MaterializeCatchScope(isolate_, CurrentContext()); | 10685 return MaterializeCatchScope(isolate_, CurrentContext()); |
| 10558 case ScopeIterator::ScopeTypeClosure: | 10686 case ScopeIterator::ScopeTypeClosure: |
| 10559 // Materialize the content of the closure scope into a JSObject. | 10687 // Materialize the content of the closure scope into a JSObject. |
| 10560 return MaterializeClosure(isolate_, CurrentContext()); | 10688 return MaterializeClosure(isolate_, CurrentContext()); |
| 10561 } | 10689 } |
| 10562 UNREACHABLE(); | 10690 UNREACHABLE(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10622 default: | 10750 default: |
| 10623 UNREACHABLE(); | 10751 UNREACHABLE(); |
| 10624 } | 10752 } |
| 10625 PrintF("\n"); | 10753 PrintF("\n"); |
| 10626 } | 10754 } |
| 10627 #endif | 10755 #endif |
| 10628 | 10756 |
| 10629 private: | 10757 private: |
| 10630 Isolate* isolate_; | 10758 Isolate* isolate_; |
| 10631 JavaScriptFrame* frame_; | 10759 JavaScriptFrame* frame_; |
| 10760 int inlined_frame_index_; |
| 10632 Handle<JSFunction> function_; | 10761 Handle<JSFunction> function_; |
| 10633 Handle<Context> context_; | 10762 Handle<Context> context_; |
| 10634 bool local_done_; | 10763 bool local_done_; |
| 10635 bool at_local_; | 10764 bool at_local_; |
| 10636 | 10765 |
| 10637 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 10766 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
| 10638 }; | 10767 }; |
| 10639 | 10768 |
| 10640 | 10769 |
| 10641 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 10770 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
| 10642 HandleScope scope(isolate); | 10771 HandleScope scope(isolate); |
| 10643 ASSERT(args.length() == 2); | 10772 ASSERT(args.length() == 2); |
| 10644 | 10773 |
| 10645 // Check arguments. | 10774 // Check arguments. |
| 10646 Object* check; | 10775 Object* check; |
| 10647 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 10776 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 10648 RUNTIME_ARGUMENTS(isolate, args)); | 10777 RUNTIME_ARGUMENTS(isolate, args)); |
| 10649 if (!maybe_check->ToObject(&check)) return maybe_check; | 10778 if (!maybe_check->ToObject(&check)) return maybe_check; |
| 10650 } | 10779 } |
| 10651 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10780 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
| 10652 | 10781 |
| 10653 // Get the frame where the debugging is performed. | 10782 // Get the frame where the debugging is performed. |
| 10654 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 10783 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 10655 JavaScriptFrameIterator it(isolate, id); | 10784 JavaScriptFrameIterator it(isolate, id); |
| 10656 JavaScriptFrame* frame = it.frame(); | 10785 JavaScriptFrame* frame = it.frame(); |
| 10657 | 10786 |
| 10658 // Count the visible scopes. | 10787 // Count the visible scopes. |
| 10659 int n = 0; | 10788 int n = 0; |
| 10660 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { | 10789 for (ScopeIterator it(isolate, frame, 0); |
| 10790 !it.Done(); |
| 10791 it.Next()) { |
| 10661 n++; | 10792 n++; |
| 10662 } | 10793 } |
| 10663 | 10794 |
| 10664 return Smi::FromInt(n); | 10795 return Smi::FromInt(n); |
| 10665 } | 10796 } |
| 10666 | 10797 |
| 10667 | 10798 |
| 10668 static const int kScopeDetailsTypeIndex = 0; | 10799 static const int kScopeDetailsTypeIndex = 0; |
| 10669 static const int kScopeDetailsObjectIndex = 1; | 10800 static const int kScopeDetailsObjectIndex = 1; |
| 10670 static const int kScopeDetailsSize = 2; | 10801 static const int kScopeDetailsSize = 2; |
| 10671 | 10802 |
| 10672 // Return an array with scope details | 10803 // Return an array with scope details |
| 10673 // args[0]: number: break id | 10804 // args[0]: number: break id |
| 10674 // args[1]: number: frame index | 10805 // args[1]: number: frame index |
| 10675 // args[2]: number: scope index | 10806 // args[2]: number: inlined frame index |
| 10807 // args[3]: number: scope index |
| 10676 // | 10808 // |
| 10677 // The array returned contains the following information: | 10809 // The array returned contains the following information: |
| 10678 // 0: Scope type | 10810 // 0: Scope type |
| 10679 // 1: Scope object | 10811 // 1: Scope object |
| 10680 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { | 10812 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { |
| 10681 HandleScope scope(isolate); | 10813 HandleScope scope(isolate); |
| 10682 ASSERT(args.length() == 3); | 10814 ASSERT(args.length() == 4); |
| 10683 | 10815 |
| 10684 // Check arguments. | 10816 // Check arguments. |
| 10685 Object* check; | 10817 Object* check; |
| 10686 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 10818 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 10687 RUNTIME_ARGUMENTS(isolate, args)); | 10819 RUNTIME_ARGUMENTS(isolate, args)); |
| 10688 if (!maybe_check->ToObject(&check)) return maybe_check; | 10820 if (!maybe_check->ToObject(&check)) return maybe_check; |
| 10689 } | 10821 } |
| 10690 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10822 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
| 10691 CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]); | 10823 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
| 10824 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
| 10692 | 10825 |
| 10693 // Get the frame where the debugging is performed. | 10826 // Get the frame where the debugging is performed. |
| 10694 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 10827 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 10695 JavaScriptFrameIterator frame_it(isolate, id); | 10828 JavaScriptFrameIterator frame_it(isolate, id); |
| 10696 JavaScriptFrame* frame = frame_it.frame(); | 10829 JavaScriptFrame* frame = frame_it.frame(); |
| 10697 | 10830 |
| 10698 // Find the requested scope. | 10831 // Find the requested scope. |
| 10699 int n = 0; | 10832 int n = 0; |
| 10700 ScopeIterator it(isolate, frame); | 10833 ScopeIterator it(isolate, frame, inlined_frame_index); |
| 10701 for (; !it.Done() && n < index; it.Next()) { | 10834 for (; !it.Done() && n < index; it.Next()) { |
| 10702 n++; | 10835 n++; |
| 10703 } | 10836 } |
| 10704 if (it.Done()) { | 10837 if (it.Done()) { |
| 10705 return isolate->heap()->undefined_value(); | 10838 return isolate->heap()->undefined_value(); |
| 10706 } | 10839 } |
| 10707 | 10840 |
| 10708 // Calculate the size of the result. | 10841 // Calculate the size of the result. |
| 10709 int details_size = kScopeDetailsSize; | 10842 int details_size = kScopeDetailsSize; |
| 10710 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 10843 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
| 10711 | 10844 |
| 10712 // Fill in scope details. | 10845 // Fill in scope details. |
| 10713 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); | 10846 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); |
| 10714 Handle<JSObject> scope_object = it.ScopeObject(); | 10847 Handle<JSObject> scope_object = it.ScopeObject(); |
| 10715 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); | 10848 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); |
| 10716 details->set(kScopeDetailsObjectIndex, *scope_object); | 10849 details->set(kScopeDetailsObjectIndex, *scope_object); |
| 10717 | 10850 |
| 10718 return *isolate->factory()->NewJSArrayWithElements(details); | 10851 return *isolate->factory()->NewJSArrayWithElements(details); |
| 10719 } | 10852 } |
| 10720 | 10853 |
| 10721 | 10854 |
| 10722 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { | 10855 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { |
| 10723 HandleScope scope(isolate); | 10856 HandleScope scope(isolate); |
| 10724 ASSERT(args.length() == 0); | 10857 ASSERT(args.length() == 0); |
| 10725 | 10858 |
| 10726 #ifdef DEBUG | 10859 #ifdef DEBUG |
| 10727 // Print the scopes for the top frame. | 10860 // Print the scopes for the top frame. |
| 10728 StackFrameLocator locator; | 10861 StackFrameLocator locator; |
| 10729 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 10862 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
| 10730 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { | 10863 for (ScopeIterator it(isolate, frame, 0); |
| 10864 !it.Done(); |
| 10865 it.Next()) { |
| 10731 it.DebugPrint(); | 10866 it.DebugPrint(); |
| 10732 } | 10867 } |
| 10733 #endif | 10868 #endif |
| 10734 return isolate->heap()->undefined_value(); | 10869 return isolate->heap()->undefined_value(); |
| 10735 } | 10870 } |
| 10736 | 10871 |
| 10737 | 10872 |
| 10738 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { | 10873 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { |
| 10739 HandleScope scope(isolate); | 10874 HandleScope scope(isolate); |
| 10740 ASSERT(args.length() == 1); | 10875 ASSERT(args.length() == 1); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11117 isolate->factory()->NewWithContext(function, new_previous, extension); | 11252 isolate->factory()->NewWithContext(function, new_previous, extension); |
| 11118 } | 11253 } |
| 11119 return scope.CloseAndEscape(new_current); | 11254 return scope.CloseAndEscape(new_current); |
| 11120 } | 11255 } |
| 11121 | 11256 |
| 11122 | 11257 |
| 11123 // Helper function to find or create the arguments object for | 11258 // Helper function to find or create the arguments object for |
| 11124 // Runtime_DebugEvaluate. | 11259 // Runtime_DebugEvaluate. |
| 11125 static Handle<Object> GetArgumentsObject(Isolate* isolate, | 11260 static Handle<Object> GetArgumentsObject(Isolate* isolate, |
| 11126 JavaScriptFrame* frame, | 11261 JavaScriptFrame* frame, |
| 11262 int inlined_frame_index, |
| 11127 Handle<JSFunction> function, | 11263 Handle<JSFunction> function, |
| 11128 Handle<SerializedScopeInfo> scope_info, | 11264 Handle<SerializedScopeInfo> scope_info, |
| 11129 const ScopeInfo<>* sinfo, | 11265 const ScopeInfo<>* sinfo, |
| 11130 Handle<Context> function_context) { | 11266 Handle<Context> function_context) { |
| 11131 // Try to find the value of 'arguments' to pass as parameter. If it is not | 11267 // Try to find the value of 'arguments' to pass as parameter. If it is not |
| 11132 // found (that is the debugged function does not reference 'arguments' and | 11268 // found (that is the debugged function does not reference 'arguments' and |
| 11133 // does not support eval) then create an 'arguments' object. | 11269 // does not support eval) then create an 'arguments' object. |
| 11134 int index; | 11270 int index; |
| 11135 if (sinfo->number_of_stack_slots() > 0) { | 11271 if (sinfo->number_of_stack_slots() > 0) { |
| 11136 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); | 11272 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); |
| 11137 if (index != -1) { | 11273 if (index != -1) { |
| 11138 return Handle<Object>(frame->GetExpression(index), isolate); | 11274 return Handle<Object>(frame->GetExpression(index), isolate); |
| 11139 } | 11275 } |
| 11140 } | 11276 } |
| 11141 | 11277 |
| 11142 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 11278 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { |
| 11143 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), | 11279 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), |
| 11144 NULL); | 11280 NULL); |
| 11145 if (index != -1) { | 11281 if (index != -1) { |
| 11146 return Handle<Object>(function_context->get(index), isolate); | 11282 return Handle<Object>(function_context->get(index), isolate); |
| 11147 } | 11283 } |
| 11148 } | 11284 } |
| 11149 | 11285 |
| 11150 const int length = frame->ComputeParametersCount(); | 11286 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
| 11287 |
| 11288 int length = frame_inspector.GetParametersCount(); |
| 11151 Handle<JSObject> arguments = | 11289 Handle<JSObject> arguments = |
| 11152 isolate->factory()->NewArgumentsObject(function, length); | 11290 isolate->factory()->NewArgumentsObject(function, length); |
| 11153 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); | 11291 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); |
| 11154 | 11292 |
| 11155 AssertNoAllocation no_gc; | 11293 AssertNoAllocation no_gc; |
| 11156 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 11294 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 11157 for (int i = 0; i < length; i++) { | 11295 for (int i = 0; i < length; i++) { |
| 11158 array->set(i, frame->GetParameter(i), mode); | 11296 array->set(i, frame_inspector.GetParameter(i), mode); |
| 11159 } | 11297 } |
| 11160 arguments->set_elements(*array); | 11298 arguments->set_elements(*array); |
| 11161 return arguments; | 11299 return arguments; |
| 11162 } | 11300 } |
| 11163 | 11301 |
| 11164 | 11302 |
| 11165 static const char kSourceStr[] = | 11303 static const char kSourceStr[] = |
| 11166 "(function(arguments,__source__){return eval(__source__);})"; | 11304 "(function(arguments,__source__){return eval(__source__);})"; |
| 11167 | 11305 |
| 11168 | 11306 |
| 11169 // Evaluate a piece of JavaScript in the context of a stack frame for | 11307 // Evaluate a piece of JavaScript in the context of a stack frame for |
| 11170 // debugging. This is accomplished by creating a new context which in its | 11308 // debugging. This is accomplished by creating a new context which in its |
| 11171 // extension part has all the parameters and locals of the function on the | 11309 // extension part has all the parameters and locals of the function on the |
| 11172 // stack frame. A function which calls eval with the code to evaluate is then | 11310 // stack frame. A function which calls eval with the code to evaluate is then |
| 11173 // compiled in this context and called in this context. As this context | 11311 // compiled in this context and called in this context. As this context |
| 11174 // replaces the context of the function on the stack frame a new (empty) | 11312 // replaces the context of the function on the stack frame a new (empty) |
| 11175 // function is created as well to be used as the closure for the context. | 11313 // function is created as well to be used as the closure for the context. |
| 11176 // This function and the context acts as replacements for the function on the | 11314 // This function and the context acts as replacements for the function on the |
| 11177 // stack frame presenting the same view of the values of parameters and | 11315 // stack frame presenting the same view of the values of parameters and |
| 11178 // local variables as if the piece of JavaScript was evaluated at the point | 11316 // local variables as if the piece of JavaScript was evaluated at the point |
| 11179 // where the function on the stack frame is currently stopped. | 11317 // where the function on the stack frame is currently stopped. |
| 11180 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { | 11318 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
| 11181 HandleScope scope(isolate); | 11319 HandleScope scope(isolate); |
| 11182 | 11320 |
| 11183 // Check the execution state and decode arguments frame and source to be | 11321 // Check the execution state and decode arguments frame and source to be |
| 11184 // evaluated. | 11322 // evaluated. |
| 11185 ASSERT(args.length() == 5); | 11323 ASSERT(args.length() == 6); |
| 11186 Object* check_result; | 11324 Object* check_result; |
| 11187 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 11325 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
| 11188 RUNTIME_ARGUMENTS(isolate, args)); | 11326 RUNTIME_ARGUMENTS(isolate, args)); |
| 11189 if (!maybe_check_result->ToObject(&check_result)) { | 11327 if (!maybe_check_result->ToObject(&check_result)) { |
| 11190 return maybe_check_result; | 11328 return maybe_check_result; |
| 11191 } | 11329 } |
| 11192 } | 11330 } |
| 11193 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 11331 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
| 11194 CONVERT_ARG_CHECKED(String, source, 2); | 11332 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
| 11195 CONVERT_BOOLEAN_CHECKED(disable_break, args[3]); | 11333 CONVERT_ARG_CHECKED(String, source, 3); |
| 11196 Handle<Object> additional_context(args[4]); | 11334 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]); |
| 11335 Handle<Object> additional_context(args[5]); |
| 11197 | 11336 |
| 11198 // Handle the processing of break. | 11337 // Handle the processing of break. |
| 11199 DisableBreak disable_break_save(disable_break); | 11338 DisableBreak disable_break_save(disable_break); |
| 11200 | 11339 |
| 11201 // Get the frame where the debugging is performed. | 11340 // Get the frame where the debugging is performed. |
| 11202 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 11341 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 11203 JavaScriptFrameIterator it(isolate, id); | 11342 JavaScriptFrameIterator it(isolate, id); |
| 11204 JavaScriptFrame* frame = it.frame(); | 11343 JavaScriptFrame* frame = it.frame(); |
| 11205 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 11344 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| 11206 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 11345 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11226 isolate->factory()->NewFunction(isolate->factory()->empty_string(), | 11365 isolate->factory()->NewFunction(isolate->factory()->empty_string(), |
| 11227 isolate->factory()->undefined_value()); | 11366 isolate->factory()->undefined_value()); |
| 11228 go_between->set_context(function->context()); | 11367 go_between->set_context(function->context()); |
| 11229 #ifdef DEBUG | 11368 #ifdef DEBUG |
| 11230 ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info()); | 11369 ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info()); |
| 11231 ASSERT(go_between_sinfo.number_of_parameters() == 0); | 11370 ASSERT(go_between_sinfo.number_of_parameters() == 0); |
| 11232 ASSERT(go_between_sinfo.number_of_context_slots() == 0); | 11371 ASSERT(go_between_sinfo.number_of_context_slots() == 0); |
| 11233 #endif | 11372 #endif |
| 11234 | 11373 |
| 11235 // Materialize the content of the local scope into a JSObject. | 11374 // Materialize the content of the local scope into a JSObject. |
| 11236 Handle<JSObject> local_scope = MaterializeLocalScope(isolate, frame); | 11375 Handle<JSObject> local_scope = MaterializeLocalScope( |
| 11376 isolate, frame, inlined_frame_index); |
| 11237 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); | 11377 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); |
| 11238 | 11378 |
| 11239 // Allocate a new context for the debug evaluation and set the extension | 11379 // Allocate a new context for the debug evaluation and set the extension |
| 11240 // object build. | 11380 // object build. |
| 11241 Handle<Context> context = | 11381 Handle<Context> context = |
| 11242 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 11382 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
| 11243 go_between); | 11383 go_between); |
| 11244 context->set_extension(*local_scope); | 11384 context->set_extension(*local_scope); |
| 11245 // Copy any with contexts present and chain them in front of this context. | 11385 // Copy any with contexts present and chain them in front of this context. |
| 11246 Handle<Context> frame_context(Context::cast(frame->context())); | 11386 Handle<Context> frame_context(Context::cast(frame->context())); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 11275 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); | 11415 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); |
| 11276 | 11416 |
| 11277 // Invoke the result of the compilation to get the evaluation function. | 11417 // Invoke the result of the compilation to get the evaluation function. |
| 11278 bool has_pending_exception; | 11418 bool has_pending_exception; |
| 11279 Handle<Object> receiver(frame->receiver(), isolate); | 11419 Handle<Object> receiver(frame->receiver(), isolate); |
| 11280 Handle<Object> evaluation_function = | 11420 Handle<Object> evaluation_function = |
| 11281 Execution::Call(compiled_function, receiver, 0, NULL, | 11421 Execution::Call(compiled_function, receiver, 0, NULL, |
| 11282 &has_pending_exception); | 11422 &has_pending_exception); |
| 11283 if (has_pending_exception) return Failure::Exception(); | 11423 if (has_pending_exception) return Failure::Exception(); |
| 11284 | 11424 |
| 11285 Handle<Object> arguments = GetArgumentsObject(isolate, frame, | 11425 Handle<Object> arguments = GetArgumentsObject(isolate, |
| 11426 frame, inlined_frame_index, |
| 11286 function, scope_info, | 11427 function, scope_info, |
| 11287 &sinfo, function_context); | 11428 &sinfo, function_context); |
| 11288 | 11429 |
| 11289 // Invoke the evaluation function and return the result. | 11430 // Invoke the evaluation function and return the result. |
| 11290 const int argc = 2; | 11431 const int argc = 2; |
| 11291 Object** argv[argc] = { arguments.location(), | 11432 Object** argv[argc] = { arguments.location(), |
| 11292 Handle<Object>::cast(source).location() }; | 11433 Handle<Object>::cast(source).location() }; |
| 11293 Handle<Object> result = | 11434 Handle<Object> result = |
| 11294 Execution::Call(Handle<JSFunction>::cast(evaluation_function), receiver, | 11435 Execution::Call(Handle<JSFunction>::cast(evaluation_function), receiver, |
| 11295 argc, argv, &has_pending_exception); | 11436 argc, argv, &has_pending_exception); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12180 EnterDebugger enter_debugger; | 12321 EnterDebugger enter_debugger; |
| 12181 return LiveObjectList::Summarize(id1, id2, filter_obj); | 12322 return LiveObjectList::Summarize(id1, id2, filter_obj); |
| 12182 #else | 12323 #else |
| 12183 return isolate->heap()->undefined_value(); | 12324 return isolate->heap()->undefined_value(); |
| 12184 #endif | 12325 #endif |
| 12185 } | 12326 } |
| 12186 | 12327 |
| 12187 #endif // ENABLE_DEBUGGER_SUPPORT | 12328 #endif // ENABLE_DEBUGGER_SUPPORT |
| 12188 | 12329 |
| 12189 | 12330 |
| 12190 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 12191 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | 12331 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
| 12192 NoHandleAllocation ha; | 12332 NoHandleAllocation ha; |
| 12193 v8::V8::ResumeProfiler(); | 12333 v8::V8::ResumeProfiler(); |
| 12194 return isolate->heap()->undefined_value(); | 12334 return isolate->heap()->undefined_value(); |
| 12195 } | 12335 } |
| 12196 | 12336 |
| 12197 | 12337 |
| 12198 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { | 12338 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { |
| 12199 NoHandleAllocation ha; | 12339 NoHandleAllocation ha; |
| 12200 v8::V8::PauseProfiler(); | 12340 v8::V8::PauseProfiler(); |
| 12201 return isolate->heap()->undefined_value(); | 12341 return isolate->heap()->undefined_value(); |
| 12202 } | 12342 } |
| 12203 | 12343 |
| 12204 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 12205 | 12344 |
| 12206 // Finds the script object from the script data. NOTE: This operation uses | 12345 // Finds the script object from the script data. NOTE: This operation uses |
| 12207 // heap traversal to find the function generated for the source position | 12346 // heap traversal to find the function generated for the source position |
| 12208 // for the requested break point. For lazily compiled functions several heap | 12347 // for the requested break point. For lazily compiled functions several heap |
| 12209 // traversals might be required rendering this operation as a rather slow | 12348 // traversals might be required rendering this operation as a rather slow |
| 12210 // operation. However for setting break points which is normally done through | 12349 // operation. However for setting break points which is normally done through |
| 12211 // some kind of user interaction the performance is not crucial. | 12350 // some kind of user interaction the performance is not crucial. |
| 12212 static Handle<Object> Runtime_GetScriptFromScriptName( | 12351 static Handle<Object> Runtime_GetScriptFromScriptName( |
| 12213 Handle<String> script_name) { | 12352 Handle<String> script_name) { |
| 12214 // Scan the heap for Script objects to find the script with the requested | 12353 // Scan the heap for Script objects to find the script with the requested |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12252 return *result; | 12391 return *result; |
| 12253 } | 12392 } |
| 12254 | 12393 |
| 12255 | 12394 |
| 12256 // Determines whether the given stack frame should be displayed in | 12395 // Determines whether the given stack frame should be displayed in |
| 12257 // a stack trace. The caller is the error constructor that asked | 12396 // a stack trace. The caller is the error constructor that asked |
| 12258 // for the stack trace to be collected. The first time a construct | 12397 // for the stack trace to be collected. The first time a construct |
| 12259 // call to this function is encountered it is skipped. The seen_caller | 12398 // call to this function is encountered it is skipped. The seen_caller |
| 12260 // in/out parameter is used to remember if the caller has been seen | 12399 // in/out parameter is used to remember if the caller has been seen |
| 12261 // yet. | 12400 // yet. |
| 12262 static bool ShowFrameInStackTrace(StackFrame* raw_frame, Object* caller, | 12401 static bool ShowFrameInStackTrace(StackFrame* raw_frame, |
| 12263 bool* seen_caller) { | 12402 Object* caller, |
| 12403 bool* seen_caller) { |
| 12264 // Only display JS frames. | 12404 // Only display JS frames. |
| 12265 if (!raw_frame->is_java_script()) | 12405 if (!raw_frame->is_java_script()) |
| 12266 return false; | 12406 return false; |
| 12267 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 12407 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
| 12268 Object* raw_fun = frame->function(); | 12408 Object* raw_fun = frame->function(); |
| 12269 // Not sure when this can happen but skip it just in case. | 12409 // Not sure when this can happen but skip it just in case. |
| 12270 if (!raw_fun->IsJSFunction()) | 12410 if (!raw_fun->IsJSFunction()) |
| 12271 return false; | 12411 return false; |
| 12272 if ((raw_fun == caller) && !(*seen_caller)) { | 12412 if ((raw_fun == caller) && !(*seen_caller)) { |
| 12273 *seen_caller = true; | 12413 *seen_caller = true; |
| 12274 return false; | 12414 return false; |
| 12275 } | 12415 } |
| 12276 // Skip all frames until we've seen the caller. Also, skip the most | 12416 // Skip all frames until we've seen the caller. |
| 12277 // obvious builtin calls. Some builtin calls (such as Number.ADD | 12417 if (!(*seen_caller)) return false; |
| 12278 // which is invoked using 'call') are very difficult to recognize | 12418 // Also, skip the most obvious builtin calls. We recognize builtins |
| 12279 // so we're leaving them in for now. | 12419 // as (1) functions called with the builtins object as the receiver and |
| 12280 return *seen_caller && !frame->receiver()->IsJSBuiltinsObject(); | 12420 // as (2) functions from native scripts called with undefined as the |
| 12421 // receiver (direct calls to helper functions in the builtins |
| 12422 // code). Some builtin calls (such as Number.ADD which is invoked |
| 12423 // using 'call') are very difficult to recognize so we're leaving |
| 12424 // them in for now. |
| 12425 if (frame->receiver()->IsJSBuiltinsObject()) { |
| 12426 return false; |
| 12427 } |
| 12428 JSFunction* fun = JSFunction::cast(raw_fun); |
| 12429 Object* raw_script = fun->shared()->script(); |
| 12430 if (frame->receiver()->IsUndefined() && raw_script->IsScript()) { |
| 12431 int script_type = Script::cast(raw_script)->type()->value(); |
| 12432 return script_type != Script::TYPE_NATIVE; |
| 12433 } |
| 12434 return true; |
| 12281 } | 12435 } |
| 12282 | 12436 |
| 12283 | 12437 |
| 12284 // Collect the raw data for a stack trace. Returns an array of 4 | 12438 // Collect the raw data for a stack trace. Returns an array of 4 |
| 12285 // element segments each containing a receiver, function, code and | 12439 // element segments each containing a receiver, function, code and |
| 12286 // native code offset. | 12440 // native code offset. |
| 12287 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { | 12441 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { |
| 12288 ASSERT_EQ(args.length(), 2); | 12442 ASSERT_EQ(args.length(), 2); |
| 12289 Handle<Object> caller = args.at<Object>(0); | 12443 Handle<Object> caller = args.at<Object>(0); |
| 12290 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); | 12444 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12658 } else { | 12812 } else { |
| 12659 // Handle last resort GC and make sure to allow future allocations | 12813 // Handle last resort GC and make sure to allow future allocations |
| 12660 // to grow the heap without causing GCs (if possible). | 12814 // to grow the heap without causing GCs (if possible). |
| 12661 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12815 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12662 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 12816 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 12663 } | 12817 } |
| 12664 } | 12818 } |
| 12665 | 12819 |
| 12666 | 12820 |
| 12667 } } // namespace v8::internal | 12821 } } // namespace v8::internal |
| OLD | NEW |