| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 | 592 |
| 593 | 593 |
| 594 MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) { | 594 MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) { |
| 595 Isolate* isolate = Isolate::Current(); | 595 Isolate* isolate = Isolate::Current(); |
| 596 HandleScope scope(isolate); | 596 HandleScope scope(isolate); |
| 597 bool found_it = false; | 597 bool found_it = false; |
| 598 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); | 598 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); |
| 599 if (!found_it) return isolate->heap()->undefined_value(); | 599 if (!found_it) return isolate->heap()->undefined_value(); |
| 600 Handle<JSFunction> function(holder, isolate); | 600 Handle<JSFunction> function(holder, isolate); |
| 601 | 601 |
| 602 if (function->shared()->native()) return isolate->heap()->null_value(); |
| 602 // Find the top invocation of the function by traversing frames. | 603 // Find the top invocation of the function by traversing frames. |
| 603 List<JSFunction*> functions(2); | 604 List<JSFunction*> functions(2); |
| 604 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { | 605 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 605 JavaScriptFrame* frame = it.frame(); | 606 JavaScriptFrame* frame = it.frame(); |
| 606 frame->GetFunctions(&functions); | 607 frame->GetFunctions(&functions); |
| 607 for (int i = functions.length() - 1; i >= 0; i--) { | 608 for (int i = functions.length() - 1; i >= 0; i--) { |
| 608 // Skip all frames that aren't invocations of the given function. | 609 // Skip all frames that aren't invocations of the given function. |
| 609 if (functions[i] != *function) continue; | 610 if (functions[i] != *function) continue; |
| 610 | 611 |
| 611 if (i > 0) { | 612 if (i > 0) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 }; | 726 }; |
| 726 | 727 |
| 727 | 728 |
| 728 MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) { | 729 MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) { |
| 729 Isolate* isolate = Isolate::Current(); | 730 Isolate* isolate = Isolate::Current(); |
| 730 HandleScope scope(isolate); | 731 HandleScope scope(isolate); |
| 731 AssertNoAllocation no_alloc; | 732 AssertNoAllocation no_alloc; |
| 732 bool found_it = false; | 733 bool found_it = false; |
| 733 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); | 734 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); |
| 734 if (!found_it) return isolate->heap()->undefined_value(); | 735 if (!found_it) return isolate->heap()->undefined_value(); |
| 736 if (holder->shared()->native()) return isolate->heap()->null_value(); |
| 735 Handle<JSFunction> function(holder, isolate); | 737 Handle<JSFunction> function(holder, isolate); |
| 736 | 738 |
| 737 FrameFunctionIterator it(isolate, no_alloc); | 739 FrameFunctionIterator it(isolate, no_alloc); |
| 738 | 740 |
| 739 // Find the function from the frames. | 741 // Find the function from the frames. |
| 740 if (!it.Find(*function)) { | 742 if (!it.Find(*function)) { |
| 741 // No frame corresponding to the given function found. Return null. | 743 // No frame corresponding to the given function found. Return null. |
| 742 return isolate->heap()->null_value(); | 744 return isolate->heap()->null_value(); |
| 743 } | 745 } |
| 744 | 746 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 794 } |
| 793 | 795 |
| 794 | 796 |
| 795 const AccessorDescriptor Accessors::ObjectPrototype = { | 797 const AccessorDescriptor Accessors::ObjectPrototype = { |
| 796 ObjectGetPrototype, | 798 ObjectGetPrototype, |
| 797 ObjectSetPrototype, | 799 ObjectSetPrototype, |
| 798 0 | 800 0 |
| 799 }; | 801 }; |
| 800 | 802 |
| 801 } } // namespace v8::internal | 803 } } // namespace v8::internal |
| OLD | NEW |