OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) { | 596 MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) { |
597 Isolate* isolate = Isolate::Current(); | 597 Isolate* isolate = Isolate::Current(); |
598 HandleScope scope(isolate); | 598 HandleScope scope(isolate); |
599 bool found_it = false; | 599 bool found_it = false; |
600 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); | 600 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); |
601 if (!found_it) return isolate->heap()->undefined_value(); | 601 if (!found_it) return isolate->heap()->undefined_value(); |
602 Handle<JSFunction> function(holder, isolate); | 602 Handle<JSFunction> function(holder, isolate); |
603 | 603 |
604 // Find the top invocation of the function by traversing frames. | 604 // Find the top invocation of the function by traversing frames. |
605 List<JSFunction*> functions(2); | 605 List<JSFunction*> functions(2); |
606 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) { | 606 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
607 JavaScriptFrame* frame = it.frame(); | 607 JavaScriptFrame* frame = it.frame(); |
608 frame->GetFunctions(&functions); | 608 frame->GetFunctions(&functions); |
609 for (int i = functions.length() - 1; i >= 0; i--) { | 609 for (int i = functions.length() - 1; i >= 0; i--) { |
610 // Skip all frames that aren't invocations of the given function. | 610 // Skip all frames that aren't invocations of the given function. |
611 if (functions[i] != *function) continue; | 611 if (functions[i] != *function) continue; |
612 | 612 |
613 if (i > 0) { | 613 if (i > 0) { |
614 // The function in question was inlined. Inlined functions have the | 614 // The function in question was inlined. Inlined functions have the |
615 // correct number of arguments and no allocated arguments object, so | 615 // correct number of arguments and no allocated arguments object, so |
616 // we can construct a fresh one by interpreting the function's | 616 // we can construct a fresh one by interpreting the function's |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) { | 685 MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) { |
686 Isolate* isolate = Isolate::Current(); | 686 Isolate* isolate = Isolate::Current(); |
687 HandleScope scope(isolate); | 687 HandleScope scope(isolate); |
688 AssertNoAllocation no_alloc; | 688 AssertNoAllocation no_alloc; |
689 bool found_it = false; | 689 bool found_it = false; |
690 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); | 690 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it); |
691 if (!found_it) return isolate->heap()->undefined_value(); | 691 if (!found_it) return isolate->heap()->undefined_value(); |
692 Handle<JSFunction> function(holder, isolate); | 692 Handle<JSFunction> function(holder, isolate); |
693 | 693 |
694 List<JSFunction*> functions(2); | 694 List<JSFunction*> functions(2); |
695 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) { | 695 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
696 JavaScriptFrame* frame = it.frame(); | 696 JavaScriptFrame* frame = it.frame(); |
697 frame->GetFunctions(&functions); | 697 frame->GetFunctions(&functions); |
698 for (int i = functions.length() - 1; i >= 0; i--) { | 698 for (int i = functions.length() - 1; i >= 0; i--) { |
699 if (functions[i] == *function) { | 699 if (functions[i] == *function) { |
700 // Once we have found the frame, we need to go to the caller | 700 // Once we have found the frame, we need to go to the caller |
701 // frame. This may require skipping through a number of top-level | 701 // frame. This may require skipping through a number of top-level |
702 // frames, e.g. frames for scripts not functions. | 702 // frames, e.g. frames for scripts not functions. |
703 if (i > 0) { | 703 if (i > 0) { |
704 ASSERT(!functions[i - 1]->shared()->is_toplevel()); | 704 ASSERT(!functions[i - 1]->shared()->is_toplevel()); |
705 return CheckNonStrictCallerOrThrow(isolate, functions[i - 1]); | 705 return CheckNonStrictCallerOrThrow(isolate, functions[i - 1]); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 757 } |
758 | 758 |
759 | 759 |
760 const AccessorDescriptor Accessors::ObjectPrototype = { | 760 const AccessorDescriptor Accessors::ObjectPrototype = { |
761 ObjectGetPrototype, | 761 ObjectGetPrototype, |
762 ObjectSetPrototype, | 762 ObjectSetPrototype, |
763 0 | 763 0 |
764 }; | 764 }; |
765 | 765 |
766 } } // namespace v8::internal | 766 } } // namespace v8::internal |
OLD | NEW |