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