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