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

Side by Side Diff: src/runtime.cc

Issue 115855: Improve debugger property lookup (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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 | « no previous file | 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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 5501 matching lines...) Expand 10 before | Expand all | Expand 10 after
5512 result->holder())->FastPropertyAt(result->GetFieldIndex()); 5512 result->holder())->FastPropertyAt(result->GetFieldIndex());
5513 if (value->IsTheHole()) { 5513 if (value->IsTheHole()) {
5514 return Heap::undefined_value(); 5514 return Heap::undefined_value();
5515 } 5515 }
5516 return value; 5516 return value;
5517 case CONSTANT_FUNCTION: 5517 case CONSTANT_FUNCTION:
5518 return result->GetConstantFunction(); 5518 return result->GetConstantFunction();
5519 case CALLBACKS: { 5519 case CALLBACKS: {
5520 Object* structure = result->GetCallbackObject(); 5520 Object* structure = result->GetCallbackObject();
5521 if (structure->IsProxy() || structure->IsAccessorInfo()) { 5521 if (structure->IsProxy() || structure->IsAccessorInfo()) {
5522 if (Debug::debugger_entry()) { 5522 value = receiver->GetPropertyWithCallback(
5523 // SaveContext scope. It will restore debugger context after the 5523 receiver, structure, name, result->holder());
5524 // getter execution.
5525 SaveContext save;
5526 Top::set_context(*Debug::debugger_entry()->GetContext());
5527 value = receiver->GetPropertyWithCallback(
5528 receiver, structure, name, result->holder());
5529 } else {
5530 value = receiver->GetPropertyWithCallback(
5531 receiver, structure, name, result->holder());
5532 }
5533 if (value->IsException()) { 5524 if (value->IsException()) {
5534 value = Top::pending_exception(); 5525 value = Top::pending_exception();
5535 Top::clear_pending_exception(); 5526 Top::clear_pending_exception();
5536 if (caught_exception != NULL) { 5527 if (caught_exception != NULL) {
5537 *caught_exception = true; 5528 *caught_exception = true;
5538 } 5529 }
5539 } 5530 }
5540 return value; 5531 return value;
5541 } else { 5532 } else {
5542 return Heap::undefined_value(); 5533 return Heap::undefined_value();
(...skipping 25 matching lines...) Expand all
5568 // Items 2-4 are only filled if the property has either a getter or a setter 5559 // Items 2-4 are only filled if the property has either a getter or a setter
5569 // defined through __defineGetter__ and/or __defineSetter__. 5560 // defined through __defineGetter__ and/or __defineSetter__.
5570 static Object* Runtime_DebugGetPropertyDetails(Arguments args) { 5561 static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
5571 HandleScope scope; 5562 HandleScope scope;
5572 5563
5573 ASSERT(args.length() == 2); 5564 ASSERT(args.length() == 2);
5574 5565
5575 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5566 CONVERT_ARG_CHECKED(JSObject, obj, 0);
5576 CONVERT_ARG_CHECKED(String, name, 1); 5567 CONVERT_ARG_CHECKED(String, name, 1);
5577 5568
5569 // Make sure to set the current context to the context before the debugger was
5570 // entered (if the debugger is entered). The reason for switching context here
5571 // is that for some property lookups (accessors and interceptors) callbacks
5572 // into the embedding application can occour, and the embedding application
5573 // could have the assumption that its own global context is the current
5574 // context and not some internal debugger context.
5575 SaveContext save;
5576 if (Debug::InDebugger()) {
5577 Top::set_context(*Debug::debugger_entry()->GetContext());
5578 }
5579
5578 // Skip the global proxy as it has no properties and always delegates to the 5580 // Skip the global proxy as it has no properties and always delegates to the
5579 // real global object. 5581 // real global object.
5580 if (obj->IsJSGlobalProxy()) { 5582 if (obj->IsJSGlobalProxy()) {
5581 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); 5583 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype()));
5582 } 5584 }
5583 5585
5584 5586
5585 // Check if the name is trivially convertible to an index and get the element 5587 // Check if the name is trivially convertible to an index and get the element
5586 // if so. 5588 // if so.
5587 uint32_t index; 5589 uint32_t index;
(...skipping 14 matching lines...) Expand all
5602 jsproto->LocalLookup(*name, &result); 5604 jsproto->LocalLookup(*name, &result);
5603 if (result.IsProperty()) { 5605 if (result.IsProperty()) {
5604 break; 5606 break;
5605 } 5607 }
5606 if (i < length - 1) { 5608 if (i < length - 1) {
5607 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5609 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5608 } 5610 }
5609 } 5611 }
5610 5612
5611 if (result.IsProperty()) { 5613 if (result.IsProperty()) {
5614 // LookupResult is not GC safe as all its members are raw object pointers.
5615 // When calling DebugLookupResultValue GC can happen as this might invoke
5616 // callbacks. After the call to DebugLookupResultValue the callback object
5617 // in the LookupResult might still be needed. Put it into a handle for later
5618 // use.
5619 PropertyType result_type = result.type();
5620 Handle<Object> result_callback_obj;
5621 if (result_type == CALLBACKS) {
5622 result_callback_obj = Handle<Object>(result.GetCallbackObject());
5623 }
5624
5625 // Find the actual value. Don't use result after this call as it's content
5626 // can be invalid.
5612 bool caught_exception = false; 5627 bool caught_exception = false;
5613 Object* value = DebugLookupResultValue(*obj, *name, &result, 5628 Object* value = DebugLookupResultValue(*obj, *name, &result,
5614 &caught_exception); 5629 &caught_exception);
5615 if (value->IsFailure()) return value; 5630 if (value->IsFailure()) return value;
5616 Handle<Object> value_handle(value); 5631 Handle<Object> value_handle(value);
5632
5617 // If the callback object is a fixed array then it contains JavaScript 5633 // If the callback object is a fixed array then it contains JavaScript
5618 // getter and/or setter. 5634 // getter and/or setter.
5619 bool hasJavaScriptAccessors = result.type() == CALLBACKS && 5635 bool hasJavaScriptAccessors = result_type == CALLBACKS &&
5620 result.GetCallbackObject()->IsFixedArray(); 5636 result_callback_obj->IsFixedArray();
5621 Handle<FixedArray> details = 5637 Handle<FixedArray> details =
5622 Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2); 5638 Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
5623 details->set(0, *value_handle); 5639 details->set(0, *value_handle);
5624 details->set(1, result.GetPropertyDetails().AsSmi()); 5640 details->set(1, result.GetPropertyDetails().AsSmi());
5625 if (hasJavaScriptAccessors) { 5641 if (hasJavaScriptAccessors) {
5626 details->set(2, 5642 details->set(2,
5627 caught_exception ? Heap::true_value() : Heap::false_value()); 5643 caught_exception ? Heap::true_value() : Heap::false_value());
5628 details->set(3, FixedArray::cast(result.GetCallbackObject())->get(0)); 5644 details->set(3, FixedArray::cast(result.GetCallbackObject())->get(0));
5629 details->set(4, FixedArray::cast(result.GetCallbackObject())->get(1)); 5645 details->set(4, FixedArray::cast(result.GetCallbackObject())->get(1));
5630 } 5646 }
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
7052 } else { 7068 } else {
7053 // Handle last resort GC and make sure to allow future allocations 7069 // Handle last resort GC and make sure to allow future allocations
7054 // to grow the heap without causing GCs (if possible). 7070 // to grow the heap without causing GCs (if possible).
7055 Counters::gc_last_resort_from_js.Increment(); 7071 Counters::gc_last_resort_from_js.Increment();
7056 Heap::CollectAllGarbage(); 7072 Heap::CollectAllGarbage();
7057 } 7073 }
7058 } 7074 }
7059 7075
7060 7076
7061 } } // namespace v8::internal 7077 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698