Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/runtime.cc

Issue 235083004: Introduce Object::DebugGetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
10721 Object* receiver,
10722 Name* name,
10723 LookupResult* result,
10724 bool* caught_exception) {
10725 Object* value;
10726 if (result->IsTransition()) return heap->undefined_value();
10727 switch (result->type()) {
10728 case NORMAL:
10729 value = result->holder()->GetNormalizedProperty(result);
10730 if (value->IsTheHole()) {
10731 return heap->undefined_value();
10732 }
10733 return value;
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 }
10746 case CONSTANT:
10747 return result->GetConstant();
10748 case CALLBACKS: {
10749 Object* structure = result->GetCallbackObject();
10750 if (structure->IsForeign() || structure->IsAccessorInfo()) {
ulan 2014/04/14 08:39:35 After this change, we no longer check for: structu
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:
10769 return heap->undefined_value();
ulan 2014/04/14 08:39:35 After this change, this can return other values.
10770 case HANDLER:
10771 case NONEXISTENT:
10772 UNREACHABLE();
10773 return heap->undefined_value();
10774 }
10775 UNREACHABLE(); // keep the compiler happy
10776 return heap->undefined_value();
10777 }
10778
10779
10780 // Get debugger related details for an object property. 10720 // Get debugger related details for an object property.
10781 // args[0]: object holding property 10721 // args[0]: object holding property
10782 // args[1]: name of the property 10722 // args[1]: name of the property
10783 // 10723 //
10784 // The array returned contains the following information: 10724 // The array returned contains the following information:
10785 // 0: Property value 10725 // 0: Property value
10786 // 1: Property details 10726 // 1: Property details
10787 // 2: Property value is exception 10727 // 2: Property value is exception
10788 // 3: Getter function if defined 10728 // 3: Getter function if defined
10789 // 4: Setter function if defined 10729 // 4: Setter function if defined
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
10840 jsproto->LocalLookup(*name, &result); 10780 jsproto->LocalLookup(*name, &result);
10841 if (result.IsFound()) { 10781 if (result.IsFound()) {
10842 // LookupResult is not GC safe as it holds raw object pointers. 10782 // 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 10783 // GC can happen later in this code so put the required fields into
10844 // local variables using handles when required for later use. 10784 // local variables using handles when required for later use.
10845 Handle<Object> result_callback_obj; 10785 Handle<Object> result_callback_obj;
10846 if (result.IsPropertyCallbacks()) { 10786 if (result.IsPropertyCallbacks()) {
10847 result_callback_obj = Handle<Object>(result.GetCallbackObject(), 10787 result_callback_obj = Handle<Object>(result.GetCallbackObject(),
10848 isolate); 10788 isolate);
10849 } 10789 }
10850 Smi* property_details = result.GetPropertyDetails().AsSmi(); 10790
10851 // DebugLookupResultValue can cause GC so details from LookupResult needs 10791 bool has_caught;
10852 // to be copied to handles before this. 10792 Handle<Object> value = Object::DebugGetProperty(
10853 bool caught_exception = false; 10793 obj, name, &result, &has_caught);
10854 Object* raw_value;
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 10794
10862 // If the callback object is a fixed array then it contains JavaScript 10795 // If the callback object is a fixed array then it contains JavaScript
10863 // getter and/or setter. 10796 // getter and/or setter.
10864 bool hasJavaScriptAccessors = result.IsPropertyCallbacks() && 10797 bool has_js_accessors = result.IsPropertyCallbacks() &&
10865 result_callback_obj->IsAccessorPair(); 10798 result_callback_obj->IsAccessorPair();
10866 Handle<FixedArray> details = 10799 Handle<FixedArray> details =
10867 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); 10800 isolate->factory()->NewFixedArray(has_js_accessors ? 5 : 2);
10868 details->set(0, *value); 10801 details->set(0, *value);
10869 details->set(1, property_details); 10802 details->set(1, result.GetPropertyDetails().AsSmi());
10870 if (hasJavaScriptAccessors) { 10803 if (has_js_accessors) {
10871 AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); 10804 AccessorPair* accessors = AccessorPair::cast(*result_callback_obj);
10872 details->set(2, isolate->heap()->ToBoolean(caught_exception)); 10805 details->set(2, isolate->heap()->ToBoolean(has_caught));
10873 details->set(3, accessors->GetComponent(ACCESSOR_GETTER)); 10806 details->set(3, accessors->GetComponent(ACCESSOR_GETTER));
10874 details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); 10807 details->set(4, accessors->GetComponent(ACCESSOR_SETTER));
10875 } 10808 }
10876 10809
10877 return *isolate->factory()->NewJSArrayWithElements(details); 10810 return *isolate->factory()->NewJSArrayWithElements(details);
10878 } 10811 }
10879 if (i < length - 1) { 10812 if (i < length - 1) {
10880 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 10813 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
10881 } 10814 }
10882 } 10815 }
10883 10816
10884 return isolate->heap()->undefined_value(); 10817 return isolate->heap()->undefined_value();
10885 } 10818 }
10886 10819
10887 10820
10888 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { 10821 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) {
10889 HandleScope scope(isolate); 10822 HandleScope scope(isolate);
10890 10823
10891 ASSERT(args.length() == 2); 10824 ASSERT(args.length() == 2);
10892 10825
10893 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10826 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10894 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 10827 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
10895 10828
10896 LookupResult result(isolate); 10829 LookupResult result(isolate);
10897 obj->Lookup(*name, &result); 10830 obj->Lookup(*name, &result);
10898 if (result.IsFound()) { 10831 return *Object::DebugGetProperty(obj, name, &result);
10899 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
10900 }
10901 return isolate->heap()->undefined_value();
10902 } 10832 }
10903 10833
10904 10834
10905 // Return the property type calculated from the property details. 10835 // Return the property type calculated from the property details.
10906 // args[0]: smi with property details. 10836 // args[0]: smi with property details.
10907 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { 10837 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) {
10908 SealHandleScope shs(isolate); 10838 SealHandleScope shs(isolate);
10909 ASSERT(args.length() == 1); 10839 ASSERT(args.length() == 1);
10910 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 10840 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10911 return Smi::FromInt(static_cast<int>(details.type())); 10841 return Smi::FromInt(static_cast<int>(details.type()));
(...skipping 4240 matching lines...) Expand 10 before | Expand all | Expand 10 after
15152 } 15082 }
15153 } 15083 }
15154 15084
15155 15085
15156 void Runtime::OutOfMemory() { 15086 void Runtime::OutOfMemory() {
15157 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15087 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15158 UNREACHABLE(); 15088 UNREACHABLE();
15159 } 15089 }
15160 15090
15161 } } // namespace v8::internal 15091 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698