OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 10700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10711 | 10711 |
10712 | 10712 |
10713 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { | 10713 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { |
10714 SealHandleScope shs(isolate); | 10714 SealHandleScope shs(isolate); |
10715 ASSERT(args.length() == 0); | 10715 ASSERT(args.length() == 0); |
10716 isolate->stack_guard()->DebugBreak(); | 10716 isolate->stack_guard()->DebugBreak(); |
10717 return isolate->heap()->undefined_value(); | 10717 return isolate->heap()->undefined_value(); |
10718 } | 10718 } |
10719 | 10719 |
10720 | 10720 |
10721 static MaybeObject* DebugLookupResultValue(Heap* heap, | 10721 static Handle<Object> DebugLookupResultValue(Isolate* isolate, |
10722 Object* receiver, | 10722 Handle<Object> receiver, |
10723 Name* name, | 10723 Handle<Name> name, |
10724 LookupResult* result, | 10724 LookupResult* result, |
10725 bool* caught_exception) { | 10725 bool* has_caught = NULL) { |
10726 Object* value; | 10726 Handle<Object> value = isolate->factory()->undefined_value(); |
10727 if (result->IsTransition()) return heap->undefined_value(); | 10727 if (!result->IsFound()) return value; |
10728 switch (result->type()) { | 10728 switch (result->type()) { |
10729 case NORMAL: | 10729 case NORMAL: |
10730 value = result->holder()->GetNormalizedProperty(result); | 10730 value = JSObject::GetNormalizedProperty( |
10731 if (value->IsTheHole()) { | 10731 handle(result->holder(), isolate), result); |
10732 return heap->undefined_value(); | 10732 break; |
| 10733 case FIELD: |
| 10734 value = JSObject::FastPropertyAt(handle(result->holder(), isolate), |
| 10735 result->representation(), |
| 10736 result->GetFieldIndex().field_index()); |
| 10737 break; |
| 10738 case CONSTANT: |
| 10739 return handle(result->GetConstant(), isolate); |
| 10740 case CALLBACKS: { |
| 10741 Handle<Object> structure(result->GetCallbackObject(), isolate); |
| 10742 if (structure->IsForeign() || structure->IsAccessorInfo()) { |
| 10743 MaybeHandle<Object> obj = JSObject::GetPropertyWithCallback( |
| 10744 handle(result->holder(), isolate), receiver, structure, name); |
| 10745 if (!obj.ToHandle(&value)) { |
| 10746 value = handle(isolate->pending_exception(), isolate); |
| 10747 isolate->clear_pending_exception(); |
| 10748 if (has_caught != NULL) *has_caught = true; |
| 10749 return value; |
| 10750 } |
10733 } | 10751 } |
10734 return value; | 10752 break; |
10735 case FIELD: { | |
10736 Object* value; | |
10737 MaybeObject* maybe_value = | |
10738 JSObject::cast(result->holder())->FastPropertyAt( | |
10739 result->representation(), | |
10740 result->GetFieldIndex().field_index()); | |
10741 if (!maybe_value->To(&value)) return maybe_value; | |
10742 if (value->IsTheHole()) { | |
10743 return heap->undefined_value(); | |
10744 } | |
10745 return value; | |
10746 } | |
10747 case CONSTANT: | |
10748 return result->GetConstant(); | |
10749 case CALLBACKS: { | |
10750 Object* structure = result->GetCallbackObject(); | |
10751 if (structure->IsForeign() || structure->IsAccessorInfo()) { | |
10752 Isolate* isolate = heap->isolate(); | |
10753 HandleScope scope(isolate); | |
10754 MaybeHandle<Object> maybe_value = JSObject::GetPropertyWithCallback( | |
10755 handle(result->holder(), isolate), | |
10756 handle(receiver, isolate), | |
10757 handle(structure, isolate), | |
10758 handle(name, isolate)); | |
10759 Handle<Object> value; | |
10760 if (maybe_value.ToHandle(&value)) return *value; | |
10761 Object* exception = heap->isolate()->pending_exception(); | |
10762 heap->isolate()->clear_pending_exception(); | |
10763 if (caught_exception != NULL) *caught_exception = true; | |
10764 return exception; | |
10765 } else { | |
10766 return heap->undefined_value(); | |
10767 } | |
10768 } | 10753 } |
10769 case INTERCEPTOR: | 10754 case INTERCEPTOR: |
10770 return heap->undefined_value(); | 10755 break; |
10771 case HANDLER: | 10756 case HANDLER: |
10772 case NONEXISTENT: | 10757 case NONEXISTENT: |
10773 UNREACHABLE(); | 10758 UNREACHABLE(); |
10774 return heap->undefined_value(); | 10759 break; |
10775 } | 10760 } |
10776 UNREACHABLE(); // keep the compiler happy | 10761 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
10777 return heap->undefined_value(); | 10762 return value->IsTheHole() |
| 10763 ? Handle<Object>::cast(isolate->factory()->undefined_value()) : value; |
10778 } | 10764 } |
10779 | 10765 |
10780 | 10766 |
10781 // Get debugger related details for an object property. | 10767 // Get debugger related details for an object property. |
10782 // args[0]: object holding property | 10768 // args[0]: object holding property |
10783 // args[1]: name of the property | 10769 // args[1]: name of the property |
10784 // | 10770 // |
10785 // The array returned contains the following information: | 10771 // The array returned contains the following information: |
10786 // 0: Property value | 10772 // 0: Property value |
10787 // 1: Property details | 10773 // 1: Property details |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10841 jsproto->LocalLookup(*name, &result); | 10827 jsproto->LocalLookup(*name, &result); |
10842 if (result.IsFound()) { | 10828 if (result.IsFound()) { |
10843 // LookupResult is not GC safe as it holds raw object pointers. | 10829 // LookupResult is not GC safe as it holds raw object pointers. |
10844 // GC can happen later in this code so put the required fields into | 10830 // GC can happen later in this code so put the required fields into |
10845 // local variables using handles when required for later use. | 10831 // local variables using handles when required for later use. |
10846 Handle<Object> result_callback_obj; | 10832 Handle<Object> result_callback_obj; |
10847 if (result.IsPropertyCallbacks()) { | 10833 if (result.IsPropertyCallbacks()) { |
10848 result_callback_obj = Handle<Object>(result.GetCallbackObject(), | 10834 result_callback_obj = Handle<Object>(result.GetCallbackObject(), |
10849 isolate); | 10835 isolate); |
10850 } | 10836 } |
10851 Smi* property_details = result.GetPropertyDetails().AsSmi(); | 10837 |
10852 // DebugLookupResultValue can cause GC so details from LookupResult needs | 10838 |
10853 // to be copied to handles before this. | 10839 bool has_caught; |
10854 bool caught_exception = false; | 10840 Handle<Object> value = DebugLookupResultValue( |
10855 Object* raw_value; | 10841 isolate, obj, name, &result, &has_caught); |
10856 { MaybeObject* maybe_raw_value = | |
10857 DebugLookupResultValue(isolate->heap(), *obj, *name, | |
10858 &result, &caught_exception); | |
10859 if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value; | |
10860 } | |
10861 Handle<Object> value(raw_value, isolate); | |
10862 | 10842 |
10863 // If the callback object is a fixed array then it contains JavaScript | 10843 // If the callback object is a fixed array then it contains JavaScript |
10864 // getter and/or setter. | 10844 // getter and/or setter. |
10865 bool hasJavaScriptAccessors = result.IsPropertyCallbacks() && | 10845 bool has_js_accessors = result.IsPropertyCallbacks() && |
10866 result_callback_obj->IsAccessorPair(); | 10846 result_callback_obj->IsAccessorPair(); |
10867 Handle<FixedArray> details = | 10847 Handle<FixedArray> details = |
10868 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); | 10848 isolate->factory()->NewFixedArray(has_js_accessors ? 5 : 2); |
10869 details->set(0, *value); | 10849 details->set(0, *value); |
10870 details->set(1, property_details); | 10850 details->set(1, result.GetPropertyDetails().AsSmi()); |
10871 if (hasJavaScriptAccessors) { | 10851 if (has_js_accessors) { |
10872 AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); | 10852 AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); |
10873 details->set(2, isolate->heap()->ToBoolean(caught_exception)); | 10853 details->set(2, isolate->heap()->ToBoolean(has_caught)); |
10874 details->set(3, accessors->GetComponent(ACCESSOR_GETTER)); | 10854 details->set(3, accessors->GetComponent(ACCESSOR_GETTER)); |
10875 details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); | 10855 details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); |
10876 } | 10856 } |
10877 | 10857 |
10878 return *isolate->factory()->NewJSArrayWithElements(details); | 10858 return *isolate->factory()->NewJSArrayWithElements(details); |
10879 } | 10859 } |
10880 if (i < length - 1) { | 10860 if (i < length - 1) { |
10881 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10861 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
10882 } | 10862 } |
10883 } | 10863 } |
10884 | 10864 |
10885 return isolate->heap()->undefined_value(); | 10865 return isolate->heap()->undefined_value(); |
10886 } | 10866 } |
10887 | 10867 |
10888 | 10868 |
10889 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { | 10869 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { |
10890 HandleScope scope(isolate); | 10870 HandleScope scope(isolate); |
10891 | 10871 |
10892 ASSERT(args.length() == 2); | 10872 ASSERT(args.length() == 2); |
10893 | 10873 |
10894 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10874 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10895 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10875 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10896 | 10876 |
10897 LookupResult result(isolate); | 10877 LookupResult result(isolate); |
10898 obj->Lookup(*name, &result); | 10878 obj->Lookup(*name, &result); |
10899 if (result.IsFound()) { | 10879 return *DebugLookupResultValue(isolate, obj, name, &result); |
10900 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); | |
10901 } | |
10902 return isolate->heap()->undefined_value(); | |
10903 } | 10880 } |
10904 | 10881 |
10905 | 10882 |
10906 // Return the property type calculated from the property details. | 10883 // Return the property type calculated from the property details. |
10907 // args[0]: smi with property details. | 10884 // args[0]: smi with property details. |
10908 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { | 10885 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { |
10909 SealHandleScope shs(isolate); | 10886 SealHandleScope shs(isolate); |
10910 ASSERT(args.length() == 1); | 10887 ASSERT(args.length() == 1); |
10911 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10888 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10912 return Smi::FromInt(static_cast<int>(details.type())); | 10889 return Smi::FromInt(static_cast<int>(details.type())); |
(...skipping 4241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15154 } | 15131 } |
15155 } | 15132 } |
15156 | 15133 |
15157 | 15134 |
15158 void Runtime::OutOfMemory() { | 15135 void Runtime::OutOfMemory() { |
15159 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15136 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15160 UNREACHABLE(); | 15137 UNREACHABLE(); |
15161 } | 15138 } |
15162 | 15139 |
15163 } } // namespace v8::internal | 15140 } } // namespace v8::internal |
OLD | NEW |