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

Side by Side Diff: src/accessors.cc

Issue 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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 | « include/v8.h ('k') | src/api.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-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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 669 }
670 670
671 671
672 672
673 673
674 674
675 static void ComputeSlotMappingForArguments(JavaScriptFrame* frame, 675 static void ComputeSlotMappingForArguments(JavaScriptFrame* frame,
676 int inlined_frame_index, 676 int inlined_frame_index,
677 Vector<SlotRef>* args_slots) { 677 Vector<SlotRef>* args_slots) {
678 AssertNoAllocation no_gc; 678 AssertNoAllocation no_gc;
679
680 int deopt_index = AstNode::kNoNumber; 679 int deopt_index = AstNode::kNoNumber;
681
682 DeoptimizationInputData* data = 680 DeoptimizationInputData* data =
683 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index); 681 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index);
684
685 TranslationIterator it(data->TranslationByteArray(), 682 TranslationIterator it(data->TranslationByteArray(),
686 data->TranslationIndex(deopt_index)->value()); 683 data->TranslationIndex(deopt_index)->value());
687
688 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); 684 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
689 ASSERT(opcode == Translation::BEGIN); 685 ASSERT(opcode == Translation::BEGIN);
690 int frame_count = it.Next(); 686 int frame_count = it.Next();
691
692 USE(frame_count); 687 USE(frame_count);
693 ASSERT(frame_count > inlined_frame_index); 688 ASSERT(frame_count > inlined_frame_index);
694
695 int frames_to_skip = inlined_frame_index; 689 int frames_to_skip = inlined_frame_index;
696 while (true) { 690 while (true) {
697 opcode = static_cast<Translation::Opcode>(it.Next()); 691 opcode = static_cast<Translation::Opcode>(it.Next());
698
699 // Skip over operands to advance to the next opcode. 692 // Skip over operands to advance to the next opcode.
700 it.Skip(Translation::NumberOfOperandsFor(opcode)); 693 it.Skip(Translation::NumberOfOperandsFor(opcode));
701
702 if (opcode == Translation::FRAME) { 694 if (opcode == Translation::FRAME) {
703 if (frames_to_skip == 0) { 695 if (frames_to_skip == 0) {
704 // We reached frame corresponding to inlined function in question. 696 // We reached the frame corresponding to the inlined function
705 // Process translation commands for arguments. 697 // in question. Process the translation commands for the
706 698 // arguments.
707 // Skip translation command for receiver. 699 //
700 // Skip the translation command for the receiver.
708 it.Skip(Translation::NumberOfOperandsFor( 701 it.Skip(Translation::NumberOfOperandsFor(
709 static_cast<Translation::Opcode>(it.Next()))); 702 static_cast<Translation::Opcode>(it.Next())));
710
711 // Compute slots for arguments. 703 // Compute slots for arguments.
712 for (int i = 0; i < args_slots->length(); ++i) { 704 for (int i = 0; i < args_slots->length(); ++i) {
713 (*args_slots)[i] = ComputeSlotForNextArgument(&it, data, frame); 705 (*args_slots)[i] = ComputeSlotForNextArgument(&it, data, frame);
714 } 706 }
715
716 return; 707 return;
717 } 708 }
718
719 frames_to_skip--; 709 frames_to_skip--;
720 } 710 }
721 } 711 }
722 712
723 UNREACHABLE(); 713 UNREACHABLE();
724 } 714 }
725 715
726 716
727 static MaybeObject* ConstructArgumentsObjectForInlinedFunction( 717 static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
728 JavaScriptFrame* frame, 718 JavaScriptFrame* frame,
729 Handle<JSFunction> inlined_function, 719 Handle<JSFunction> inlined_function,
730 int inlined_frame_index) { 720 int inlined_frame_index) {
731 Isolate* isolate = Isolate::Current(); 721 Factory* factory = Isolate::Current()->factory();
732 Factory* factory = isolate->factory();
733
734 int args_count = inlined_function->shared()->formal_parameter_count(); 722 int args_count = inlined_function->shared()->formal_parameter_count();
735
736 ScopedVector<SlotRef> args_slots(args_count); 723 ScopedVector<SlotRef> args_slots(args_count);
737
738 ComputeSlotMappingForArguments(frame, inlined_frame_index, &args_slots); 724 ComputeSlotMappingForArguments(frame, inlined_frame_index, &args_slots);
739
740 Handle<JSObject> arguments = 725 Handle<JSObject> arguments =
741 factory->NewArgumentsObject(inlined_function, args_count); 726 factory->NewArgumentsObject(inlined_function, args_count);
742
743 Handle<FixedArray> array = factory->NewFixedArray(args_count); 727 Handle<FixedArray> array = factory->NewFixedArray(args_count);
744 for (int i = 0; i < args_count; ++i) { 728 for (int i = 0; i < args_count; ++i) {
745 Handle<Object> value = args_slots[i].GetValue(); 729 Handle<Object> value = args_slots[i].GetValue();
746 array->set(i, *value); 730 array->set(i, *value);
747 } 731 }
748 arguments->set_elements(*array); 732 arguments->set_elements(*array);
749 733
750 // Return the freshly allocated arguments object. 734 // Return the freshly allocated arguments object.
751 return *arguments; 735 return *arguments;
752 } 736 }
(...skipping 10 matching lines...) Expand all
763 // Find the top invocation of the function by traversing frames. 747 // Find the top invocation of the function by traversing frames.
764 List<JSFunction*> functions(2); 748 List<JSFunction*> functions(2);
765 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) { 749 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) {
766 JavaScriptFrame* frame = it.frame(); 750 JavaScriptFrame* frame = it.frame();
767 frame->GetFunctions(&functions); 751 frame->GetFunctions(&functions);
768 for (int i = functions.length() - 1; i >= 0; i--) { 752 for (int i = functions.length() - 1; i >= 0; i--) {
769 // Skip all frames that aren't invocations of the given function. 753 // Skip all frames that aren't invocations of the given function.
770 if (functions[i] != *function) continue; 754 if (functions[i] != *function) continue;
771 755
772 if (i > 0) { 756 if (i > 0) {
773 // Function in question was inlined. 757 // The function in question was inlined. Inlined functions have the
758 // correct number of arguments and no allocated arguments object, so
759 // we can construct a fresh one by interpreting the function's
760 // deoptimization input data.
774 return ConstructArgumentsObjectForInlinedFunction(frame, function, i); 761 return ConstructArgumentsObjectForInlinedFunction(frame, function, i);
775 } else { 762 }
763
764 if (!frame->is_optimized()) {
776 // If there is an arguments variable in the stack, we return that. 765 // If there is an arguments variable in the stack, we return that.
777 int index = function->shared()->scope_info()-> 766 Handle<SerializedScopeInfo> info(function->shared()->scope_info());
778 StackSlotIndex(isolate->heap()->arguments_symbol()); 767 int index = info->StackSlotIndex(isolate->heap()->arguments_symbol());
779 if (index >= 0) { 768 if (index >= 0) {
780 Handle<Object> arguments = 769 Handle<Object> arguments(frame->GetExpression(index), isolate);
781 Handle<Object>(frame->GetExpression(index), isolate);
782 if (!arguments->IsArgumentsMarker()) return *arguments; 770 if (!arguments->IsArgumentsMarker()) return *arguments;
783 } 771 }
772 }
784 773
785 // If there isn't an arguments variable in the stack, we need to 774 // If there is no arguments variable in the stack or we have an
786 // find the frame that holds the actual arguments passed to the 775 // optimized frame, we find the frame that holds the actual arguments
787 // function on the stack. 776 // passed to the function.
788 it.AdvanceToArgumentsFrame(); 777 it.AdvanceToArgumentsFrame();
789 frame = it.frame(); 778 frame = it.frame();
790 779
791 // Get the number of arguments and construct an arguments object 780 // Get the number of arguments and construct an arguments object
792 // mirror for the right frame. 781 // mirror for the right frame.
793 const int length = frame->GetProvidedParametersCount(); 782 const int length = frame->GetProvidedParametersCount();
794 Handle<JSObject> arguments = isolate->factory()->NewArgumentsObject( 783 Handle<JSObject> arguments = isolate->factory()->NewArgumentsObject(
795 function, length); 784 function, length);
796 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); 785 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
797 786
798 // Copy the parameters to the arguments object. 787 // Copy the parameters to the arguments object.
799 ASSERT(array->length() == length); 788 ASSERT(array->length() == length);
800 for (int i = 0; i < length; i++) array->set(i, frame->GetParameter(i)); 789 for (int i = 0; i < length; i++) array->set(i, frame->GetParameter(i));
801 arguments->set_elements(*array); 790 arguments->set_elements(*array);
802 791
803 // Return the freshly allocated arguments object. 792 // Return the freshly allocated arguments object.
804 return *arguments; 793 return *arguments;
805 }
806 } 794 }
807 functions.Rewind(0); 795 functions.Rewind(0);
808 } 796 }
809 797
810 // No frame corresponding to the given function found. Return null. 798 // No frame corresponding to the given function found. Return null.
811 return isolate->heap()->null_value(); 799 return isolate->heap()->null_value();
812 } 800 }
813 801
814 802
815 const AccessorDescriptor Accessors::FunctionArguments = { 803 const AccessorDescriptor Accessors::FunctionArguments = {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 887 }
900 888
901 889
902 const AccessorDescriptor Accessors::ObjectPrototype = { 890 const AccessorDescriptor Accessors::ObjectPrototype = {
903 ObjectGetPrototype, 891 ObjectGetPrototype,
904 ObjectSetPrototype, 892 ObjectSetPrototype,
905 0 893 0
906 }; 894 };
907 895
908 } } // namespace v8::internal 896 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698