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

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 6062002: Merge 6006:6095 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 10 years 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 | « src/api.cc ('k') | src/arm/codegen-arm.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 // Restore callee-saved registers and return. 2888 // Restore callee-saved registers and return.
2889 #ifdef DEBUG 2889 #ifdef DEBUG
2890 if (FLAG_debug_code) { 2890 if (FLAG_debug_code) {
2891 __ mov(lr, Operand(pc)); 2891 __ mov(lr, Operand(pc));
2892 } 2892 }
2893 #endif 2893 #endif
2894 __ ldm(ia_w, sp, kCalleeSaved | pc.bit()); 2894 __ ldm(ia_w, sp, kCalleeSaved | pc.bit());
2895 } 2895 }
2896 2896
2897 2897
2898 // This stub performs an instanceof, calling the builtin function if 2898 // Uses registers r0 to r4. Expected input is
2899 // necessary. Uses r1 for the object, r0 for the function that it may 2899 // function in r0 (or at sp+1*ptrsz) and object in
2900 // be an instance of (these are fetched from the stack). 2900 // r1 (or at sp), depending on whether or not
2901 // args_in_registers() is true.
2901 void InstanceofStub::Generate(MacroAssembler* masm) { 2902 void InstanceofStub::Generate(MacroAssembler* masm) {
2902 // Get the object - slow case for smis (we may need to throw an exception 2903 // Fixed register usage throughout the stub:
2903 // depending on the rhs). 2904 const Register object = r1; // Object (lhs).
2904 Label slow, loop, is_instance, is_not_instance; 2905 const Register map = r3; // Map of the object.
2905 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); 2906 const Register function = r0; // Function (rhs).
2906 __ BranchOnSmi(r0, &slow); 2907 const Register prototype = r4; // Prototype of the function.
2908 const Register scratch = r2;
2909 Label slow, loop, is_instance, is_not_instance, not_js_object;
2910 if (!args_in_registers()) {
2911 __ ldr(function, MemOperand(sp, 1 * kPointerSize));
2912 __ ldr(object, MemOperand(sp, 0));
2913 }
2907 2914
2908 // Check that the left hand is a JS object and put map in r3. 2915 // Check that the left hand is a JS object and load map.
2909 __ CompareObjectType(r0, r3, r2, FIRST_JS_OBJECT_TYPE); 2916 __ BranchOnSmi(object, &slow);
2910 __ b(lt, &slow); 2917 __ IsObjectJSObjectType(object, map, scratch, &slow);
2911 __ cmp(r2, Operand(LAST_JS_OBJECT_TYPE));
2912 __ b(gt, &slow);
2913
2914 // Get the prototype of the function (r4 is result, r2 is scratch).
2915 __ ldr(r1, MemOperand(sp, 0));
2916 // r1 is function, r3 is map.
2917 2918
2918 // Look up the function and the map in the instanceof cache. 2919 // Look up the function and the map in the instanceof cache.
2919 Label miss; 2920 Label miss;
2920 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex); 2921 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex);
2921 __ cmp(r1, ip); 2922 __ cmp(object, ip);
2922 __ b(ne, &miss); 2923 __ b(ne, &miss);
2923 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex); 2924 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex);
2924 __ cmp(r3, ip); 2925 __ cmp(map, ip);
2925 __ b(ne, &miss); 2926 __ b(ne, &miss);
2926 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); 2927 __ LoadRoot(function, Heap::kInstanceofCacheAnswerRootIndex);
2927 __ pop(); 2928 __ Ret(args_in_registers() ? 0 : 2);
2928 __ pop();
2929 __ mov(pc, Operand(lr));
2930 2929
2931 __ bind(&miss); 2930 __ bind(&miss);
2932 __ TryGetFunctionPrototype(r1, r4, r2, &slow); 2931 __ TryGetFunctionPrototype(object, prototype, scratch, &slow);
2933 2932
2934 // Check that the function prototype is a JS object. 2933 // Check that the function prototype is a JS object.
2935 __ BranchOnSmi(r4, &slow); 2934 __ BranchOnSmi(prototype, &slow);
2936 __ CompareObjectType(r4, r5, r5, FIRST_JS_OBJECT_TYPE); 2935 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow);
2937 __ b(lt, &slow);
2938 __ cmp(r5, Operand(LAST_JS_OBJECT_TYPE));
2939 __ b(gt, &slow);
2940 2936
2941 __ StoreRoot(r1, Heap::kInstanceofCacheFunctionRootIndex); 2937 __ StoreRoot(object, Heap::kInstanceofCacheFunctionRootIndex);
2942 __ StoreRoot(r3, Heap::kInstanceofCacheMapRootIndex); 2938 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex);
2943 2939
2944 // Register mapping: r3 is object map and r4 is function prototype. 2940 // Register mapping: r3 is object map and r4 is function prototype.
2945 // Get prototype of object into r2. 2941 // Get prototype of object into r2.
2946 __ ldr(r2, FieldMemOperand(r3, Map::kPrototypeOffset)); 2942 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset));
2947 2943
2948 // Loop through the prototype chain looking for the function prototype. 2944 // Loop through the prototype chain looking for the function prototype.
2949 __ bind(&loop); 2945 __ bind(&loop);
2950 __ cmp(r2, Operand(r4)); 2946 __ cmp(scratch, Operand(prototype));
2951 __ b(eq, &is_instance); 2947 __ b(eq, &is_instance);
2952 __ LoadRoot(ip, Heap::kNullValueRootIndex); 2948 __ LoadRoot(ip, Heap::kNullValueRootIndex);
2953 __ cmp(r2, ip); 2949 __ cmp(scratch, ip);
2954 __ b(eq, &is_not_instance); 2950 __ b(eq, &is_not_instance);
2955 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); 2951 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset));
2956 __ ldr(r2, FieldMemOperand(r2, Map::kPrototypeOffset)); 2952 __ ldr(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset));
2957 __ jmp(&loop); 2953 __ jmp(&loop);
2958 2954
2959 __ bind(&is_instance); 2955 __ bind(&is_instance);
2960 __ mov(r0, Operand(Smi::FromInt(0))); 2956 __ mov(r0, Operand(Smi::FromInt(0)));
2961 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); 2957 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex);
2962 __ pop(); 2958 __ Ret(args_in_registers() ? 0 : 2);
2963 __ pop();
2964 __ mov(pc, Operand(lr)); // Return.
2965 2959
2966 __ bind(&is_not_instance); 2960 __ bind(&is_not_instance);
2967 __ mov(r0, Operand(Smi::FromInt(1))); 2961 __ mov(r0, Operand(Smi::FromInt(1)));
2968 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); 2962 __ Ret(args_in_registers() ? 0 : 2);
2969 __ pop(); 2963
2970 __ pop(); 2964 Label object_not_null, object_not_null_or_smi;
2971 __ mov(pc, Operand(lr)); // Return. 2965 __ bind(&not_js_object);
2966 // Before null, smi and string value checks, check that the rhs is a function
2967 // as for a non-function rhs an exception needs to be thrown.
2968 __ BranchOnSmi(function, &slow);
2969 __ CompareObjectType(function, map, scratch, JS_FUNCTION_TYPE);
2970 __ b(ne, &slow);
2971
2972 // Null is not instance of anything.
2973 __ cmp(scratch, Operand(Factory::null_value()));
2974 __ b(ne, &object_not_null);
2975 __ mov(r0, Operand(Smi::FromInt(1)));
2976 __ Ret(args_in_registers() ? 0 : 2);
2977
2978 __ bind(&object_not_null);
2979 // Smi values are not instances of anything.
2980 __ BranchOnNotSmi(object, &object_not_null_or_smi);
2981 __ mov(r0, Operand(Smi::FromInt(1)));
2982 __ Ret(args_in_registers() ? 0 : 2);
2983
2984 __ bind(&object_not_null_or_smi);
2985 // String values are not instances of anything.
2986 __ IsObjectJSStringType(object, scratch, &slow);
2987 __ mov(r0, Operand(Smi::FromInt(1)));
2988 __ Ret(args_in_registers() ? 0 : 2);
2972 2989
2973 // Slow-case. Tail call builtin. 2990 // Slow-case. Tail call builtin.
2974 __ bind(&slow); 2991 __ bind(&slow);
2975 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS); 2992 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS);
2976 } 2993 }
2977 2994
2978 2995
2979 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { 2996 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
2980 // The displacement is the offset of the last parameter (if any) 2997 // The displacement is the offset of the last parameter (if any)
2981 // relative to the frame pointer. 2998 // relative to the frame pointer.
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 __ pop(r1); 4982 __ pop(r1);
4966 __ Jump(r2); 4983 __ Jump(r2);
4967 } 4984 }
4968 4985
4969 4986
4970 #undef __ 4987 #undef __
4971 4988
4972 } } // namespace v8::internal 4989 } } // namespace v8::internal
4973 4990
4974 #endif // V8_TARGET_ARCH_ARM 4991 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698