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