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