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

Side by Side Diff: src/runtime.cc

Issue 113821: Execute accessor for the debugged property if it's a native function (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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 | test/cctest/test-debug.cc » ('j') | 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 5467 matching lines...) Expand 10 before | Expand all | Expand 10 after
5478 Object* proto = obj->GetPrototype(); 5478 Object* proto = obj->GetPrototype();
5479 while (proto->IsJSObject() && 5479 while (proto->IsJSObject() &&
5480 JSObject::cast(proto)->map()->is_hidden_prototype()) { 5480 JSObject::cast(proto)->map()->is_hidden_prototype()) {
5481 count++; 5481 count++;
5482 proto = JSObject::cast(proto)->GetPrototype(); 5482 proto = JSObject::cast(proto)->GetPrototype();
5483 } 5483 }
5484 return count; 5484 return count;
5485 } 5485 }
5486 5486
5487 5487
5488 static Object* DebugLookupResultValue(Object* receiver, LookupResult* result, 5488 static Object* DebugLookupResultValue(Object* receiver, String* name,
5489 LookupResult* result,
5489 bool* caught_exception) { 5490 bool* caught_exception) {
5490 Object* value; 5491 Object* value;
5491 switch (result->type()) { 5492 switch (result->type()) {
5492 case NORMAL: { 5493 case NORMAL: {
5493 Dictionary* dict = 5494 Dictionary* dict =
5494 JSObject::cast(result->holder())->property_dictionary(); 5495 JSObject::cast(result->holder())->property_dictionary();
5495 value = dict->ValueAt(result->GetDictionaryEntry()); 5496 value = dict->ValueAt(result->GetDictionaryEntry());
5496 if (value->IsTheHole()) { 5497 if (value->IsTheHole()) {
5497 return Heap::undefined_value(); 5498 return Heap::undefined_value();
5498 } 5499 }
5499 return value; 5500 return value;
5500 } 5501 }
5501 case FIELD: 5502 case FIELD:
5502 value = 5503 value =
5503 JSObject::cast( 5504 JSObject::cast(
5504 result->holder())->FastPropertyAt(result->GetFieldIndex()); 5505 result->holder())->FastPropertyAt(result->GetFieldIndex());
5505 if (value->IsTheHole()) { 5506 if (value->IsTheHole()) {
5506 return Heap::undefined_value(); 5507 return Heap::undefined_value();
5507 } 5508 }
5508 return value; 5509 return value;
5509 case CONSTANT_FUNCTION: 5510 case CONSTANT_FUNCTION:
5510 return result->GetConstantFunction(); 5511 return result->GetConstantFunction();
5511 case CALLBACKS: { 5512 case CALLBACKS: {
5512 Object* structure = result->GetCallbackObject(); 5513 Object* structure = result->GetCallbackObject();
5513 if (structure->IsProxy()) { 5514 if (structure->IsProxy() || structure->IsAccessorInfo()) {
5514 AccessorDescriptor* callback = 5515 if (Debug::debugger_entry()) {
5515 reinterpret_cast<AccessorDescriptor*>( 5516 // SaveContext scope. It will restore debugger context after the
5516 Proxy::cast(structure)->proxy()); 5517 // getter execution.
5517 value = (callback->getter)(receiver, callback->data); 5518 SaveContext save;
5519 Top::set_context(*Debug::debugger_entry()->GetContext());
5520 value = receiver->GetPropertyWithCallback(
5521 receiver, structure, name, result->holder());
5522 } else {
5523 value = receiver->GetPropertyWithCallback(
5524 receiver, structure, name, result->holder());
5525 }
5518 if (value->IsException()) { 5526 if (value->IsException()) {
5519 value = Top::pending_exception(); 5527 value = Top::pending_exception();
5520 Top::clear_pending_exception(); 5528 Top::clear_pending_exception();
5521 if (caught_exception != NULL) { 5529 if (caught_exception != NULL) {
5522 *caught_exception = true; 5530 *caught_exception = true;
5523 } 5531 }
5524 } 5532 }
5525 return value; 5533 return value;
5526 } else { 5534 } else {
5527 return Heap::undefined_value(); 5535 return Heap::undefined_value();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 if (result.IsProperty()) { 5596 if (result.IsProperty()) {
5589 break; 5597 break;
5590 } 5598 }
5591 if (i < length - 1) { 5599 if (i < length - 1) {
5592 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5600 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5593 } 5601 }
5594 } 5602 }
5595 5603
5596 if (result.IsProperty()) { 5604 if (result.IsProperty()) {
5597 bool caught_exception = false; 5605 bool caught_exception = false;
5598 Object* value = DebugLookupResultValue(*obj, &result, 5606 Object* value = DebugLookupResultValue(*obj, *name, &result,
5599 &caught_exception); 5607 &caught_exception);
5600 if (value->IsFailure()) return value; 5608 if (value->IsFailure()) return value;
5601 Handle<Object> value_handle(value); 5609 Handle<Object> value_handle(value);
5602 // If the callback object is a fixed array then it contains JavaScript 5610 // If the callback object is a fixed array then it contains JavaScript
5603 // getter and/or setter. 5611 // getter and/or setter.
5604 bool hasJavaScriptAccessors = result.type() == CALLBACKS && 5612 bool hasJavaScriptAccessors = result.type() == CALLBACKS &&
5605 result.GetCallbackObject()->IsFixedArray(); 5613 result.GetCallbackObject()->IsFixedArray();
5606 Handle<FixedArray> details = 5614 Handle<FixedArray> details =
5607 Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2); 5615 Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
5608 details->set(0, *value_handle); 5616 details->set(0, *value_handle);
(...skipping 15 matching lines...) Expand all
5624 HandleScope scope; 5632 HandleScope scope;
5625 5633
5626 ASSERT(args.length() == 2); 5634 ASSERT(args.length() == 2);
5627 5635
5628 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5636 CONVERT_ARG_CHECKED(JSObject, obj, 0);
5629 CONVERT_ARG_CHECKED(String, name, 1); 5637 CONVERT_ARG_CHECKED(String, name, 1);
5630 5638
5631 LookupResult result; 5639 LookupResult result;
5632 obj->Lookup(*name, &result); 5640 obj->Lookup(*name, &result);
5633 if (result.IsProperty()) { 5641 if (result.IsProperty()) {
5634 return DebugLookupResultValue(*obj, &result, NULL); 5642 return DebugLookupResultValue(*obj, *name, &result, NULL);
5635 } 5643 }
5636 return Heap::undefined_value(); 5644 return Heap::undefined_value();
5637 } 5645 }
5638 5646
5639 5647
5640 // Return the names of the local named properties. 5648 // Return the names of the local named properties.
5641 // args[0]: object 5649 // args[0]: object
5642 static Object* Runtime_DebugLocalPropertyNames(Arguments args) { 5650 static Object* Runtime_DebugLocalPropertyNames(Arguments args) {
5643 HandleScope scope; 5651 HandleScope scope;
5644 ASSERT(args.length() == 1); 5652 ASSERT(args.length() == 1);
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
7037 } else { 7045 } else {
7038 // Handle last resort GC and make sure to allow future allocations 7046 // Handle last resort GC and make sure to allow future allocations
7039 // to grow the heap without causing GCs (if possible). 7047 // to grow the heap without causing GCs (if possible).
7040 Counters::gc_last_resort_from_js.Increment(); 7048 Counters::gc_last_resort_from_js.Increment();
7041 Heap::CollectAllGarbage(); 7049 Heap::CollectAllGarbage();
7042 } 7050 }
7043 } 7051 }
7044 7052
7045 7053
7046 } } // namespace v8::internal 7054 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698