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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 6576028: X64: Port r5445... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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 | « 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 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 840
841 841
842 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 842 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
843 Comment cmnt(masm_, "[ ForInStatement"); 843 Comment cmnt(masm_, "[ ForInStatement");
844 SetStatementPosition(stmt); 844 SetStatementPosition(stmt);
845 845
846 Label loop, exit; 846 Label loop, exit;
847 ForIn loop_statement(this, stmt); 847 ForIn loop_statement(this, stmt);
848 increment_loop_depth(); 848 increment_loop_depth();
849 849
850 // Load null value as it is used several times below.
851 Register null_value = rdi;
852 __ LoadRoot(null_value, Heap::kNullValueRootIndex);
853
850 // Get the object to enumerate over. Both SpiderMonkey and JSC 854 // Get the object to enumerate over. Both SpiderMonkey and JSC
851 // ignore null and undefined in contrast to the specification; see 855 // ignore null and undefined in contrast to the specification; see
852 // ECMA-262 section 12.6.4. 856 // ECMA-262 section 12.6.4.
853 VisitForAccumulatorValue(stmt->enumerable()); 857 VisitForAccumulatorValue(stmt->enumerable());
854 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 858 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
855 __ j(equal, &exit); 859 __ j(equal, &exit);
856 __ CompareRoot(rax, Heap::kNullValueRootIndex); 860 __ cmpq(rax, null_value);
857 __ j(equal, &exit); 861 __ j(equal, &exit);
858 862
859 // Convert the object to a JS object. 863 // Convert the object to a JS object.
860 Label convert, done_convert; 864 Label convert, done_convert;
861 __ JumpIfSmi(rax, &convert); 865 __ JumpIfSmi(rax, &convert);
862 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); 866 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx);
863 __ j(above_equal, &done_convert); 867 __ j(above_equal, &done_convert);
864 __ bind(&convert); 868 __ bind(&convert);
865 __ push(rax); 869 __ push(rax);
866 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); 870 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
867 __ bind(&done_convert); 871 __ bind(&done_convert);
868 __ push(rax); 872 __ push(rax);
869 873
870 // BUG(867): Check cache validity in generated code. This is a fast 874 // Check cache validity in generated code. This is a fast case for
871 // case for the JSObject::IsSimpleEnum cache validity checks. If we 875 // the JSObject::IsSimpleEnum cache validity checks. If we cannot
872 // cannot guarantee cache validity, call the runtime system to check 876 // guarantee cache validity, call the runtime system to check cache
873 // cache validity or get the property names in a fixed array. 877 // validity or get the property names in a fixed array.
878 Label next, call_runtime;
879 Register empty_fixed_array_value = r8;
880 __ LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex);
881 Register empty_descriptor_array_value = r9;
882 __ LoadRoot(empty_descriptor_array_value,
883 Heap::kEmptyDescriptorArrayRootIndex);
884 __ movq(rcx, rax);
885 __ bind(&next);
886
887 // Check that there are no elements. Register rcx contains the
888 // current JS object we've reached through the prototype chain.
889 __ cmpq(empty_fixed_array_value,
890 FieldOperand(rcx, JSObject::kElementsOffset));
891 __ j(not_equal, &call_runtime);
892
893 // Check that instance descriptors are not empty so that we can
894 // check for an enum cache. Leave the map in rbx for the subsequent
895 // prototype load.
896 __ movq(rbx, FieldOperand(rcx, HeapObject::kMapOffset));
897 __ movq(rdx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset));
898 __ cmpq(rdx, empty_descriptor_array_value);
899 __ j(equal, &call_runtime);
900
901 // Check that there is an enum cache in the non-empty instance
902 // descriptors (rdx). This is the case if the next enumeration
903 // index field does not contain a smi.
904 __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumerationIndexOffset));
905 __ JumpIfSmi(rdx, &call_runtime);
906
907 // For all objects but the receiver, check that the cache is empty.
908 NearLabel check_prototype;
909 __ cmpq(rcx, rax);
910 __ j(equal, &check_prototype);
911 __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumCacheBridgeCacheOffset));
912 __ cmpq(rdx, empty_fixed_array_value);
913 __ j(not_equal, &call_runtime);
914
915 // Load the prototype from the map and loop if non-null.
916 __ bind(&check_prototype);
917 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
918 __ cmpq(rcx, null_value);
919 __ j(not_equal, &next);
920
921 // The enum cache is valid. Load the map of the object being
922 // iterated over and use the cache for the iteration.
923 NearLabel use_cache;
924 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset));
925 __ jmp(&use_cache);
874 926
875 // Get the set of properties to enumerate. 927 // Get the set of properties to enumerate.
928 __ bind(&call_runtime);
876 __ push(rax); // Duplicate the enumerable object on the stack. 929 __ push(rax); // Duplicate the enumerable object on the stack.
877 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); 930 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1);
878 931
879 // If we got a map from the runtime call, we can do a fast 932 // If we got a map from the runtime call, we can do a fast
880 // modification check. Otherwise, we got a fixed array, and we have 933 // modification check. Otherwise, we got a fixed array, and we have
881 // to do a slow check. 934 // to do a slow check.
882 NearLabel fixed_array; 935 NearLabel fixed_array;
883 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), 936 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
884 Heap::kMetaMapRootIndex); 937 Heap::kMetaMapRootIndex);
885 __ j(not_equal, &fixed_array); 938 __ j(not_equal, &fixed_array);
886 939
887 // We got a map in register rax. Get the enumeration cache from it. 940 // We got a map in register rax. Get the enumeration cache from it.
941 __ bind(&use_cache);
888 __ movq(rcx, FieldOperand(rax, Map::kInstanceDescriptorsOffset)); 942 __ movq(rcx, FieldOperand(rax, Map::kInstanceDescriptorsOffset));
889 __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset)); 943 __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset));
890 __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset)); 944 __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset));
891 945
892 // Setup the four remaining stack slots. 946 // Setup the four remaining stack slots.
893 __ push(rax); // Map. 947 __ push(rax); // Map.
894 __ push(rdx); // Enumeration cache. 948 __ push(rdx); // Enumeration cache.
895 __ movq(rax, FieldOperand(rdx, FixedArray::kLengthOffset)); 949 __ movq(rax, FieldOperand(rdx, FixedArray::kLengthOffset));
896 __ push(rax); // Enumeration cache length (as smi). 950 __ push(rax); // Enumeration cache length (as smi).
897 __ Push(Smi::FromInt(0)); // Initial index. 951 __ Push(Smi::FromInt(0)); // Initial index.
(...skipping 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 __ ret(0); 3845 __ ret(0);
3792 } 3846 }
3793 3847
3794 3848
3795 #undef __ 3849 #undef __
3796 3850
3797 3851
3798 } } // namespace v8::internal 3852 } } // namespace v8::internal
3799 3853
3800 #endif // V8_TARGET_ARCH_X64 3854 #endif // V8_TARGET_ARCH_X64
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