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 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2898 // r1 (or at sp), depending on whether or not | 2898 // r1 (or at sp), depending on whether or not |
2899 // args_in_registers() is true. | 2899 // args_in_registers() is true. |
2900 void InstanceofStub::Generate(MacroAssembler* masm) { | 2900 void InstanceofStub::Generate(MacroAssembler* masm) { |
2901 // Fixed register usage throughout the stub: | 2901 // Fixed register usage throughout the stub: |
2902 const Register object = r0; // Object (lhs). | 2902 const Register object = r0; // Object (lhs). |
2903 const Register map = r3; // Map of the object. | 2903 const Register map = r3; // Map of the object. |
2904 const Register function = r1; // Function (rhs). | 2904 const Register function = r1; // Function (rhs). |
2905 const Register prototype = r4; // Prototype of the function. | 2905 const Register prototype = r4; // Prototype of the function. |
2906 const Register scratch = r2; | 2906 const Register scratch = r2; |
2907 Label slow, loop, is_instance, is_not_instance, not_js_object; | 2907 Label slow, loop, is_instance, is_not_instance, not_js_object; |
2908 if (!args_in_registers()) { | 2908 if (!HasArgsInRegisters()) { |
2909 __ ldr(object, MemOperand(sp, 1 * kPointerSize)); | 2909 __ ldr(object, MemOperand(sp, 1 * kPointerSize)); |
2910 __ ldr(function, MemOperand(sp, 0)); | 2910 __ ldr(function, MemOperand(sp, 0)); |
2911 } | 2911 } |
2912 | 2912 |
2913 // Check that the left hand is a JS object and load map. | 2913 // Check that the left hand is a JS object and load map. |
2914 __ BranchOnSmi(object, ¬_js_object); | 2914 __ BranchOnSmi(object, ¬_js_object); |
2915 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); | 2915 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); |
2916 | 2916 |
2917 // Look up the function and the map in the instanceof cache. | 2917 // Look up the function and the map in the instanceof cache. |
2918 Label miss; | 2918 Label miss; |
2919 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex); | 2919 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex); |
2920 __ cmp(function, ip); | 2920 __ cmp(function, ip); |
2921 __ b(ne, &miss); | 2921 __ b(ne, &miss); |
2922 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex); | 2922 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex); |
2923 __ cmp(map, ip); | 2923 __ cmp(map, ip); |
2924 __ b(ne, &miss); | 2924 __ b(ne, &miss); |
2925 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2925 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); |
2926 __ Ret(args_in_registers() ? 0 : 2); | 2926 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2927 | 2927 |
2928 __ bind(&miss); | 2928 __ bind(&miss); |
2929 __ TryGetFunctionPrototype(function, prototype, scratch, &slow); | 2929 __ TryGetFunctionPrototype(function, prototype, scratch, &slow); |
2930 | 2930 |
2931 // Check that the function prototype is a JS object. | 2931 // Check that the function prototype is a JS object. |
2932 __ BranchOnSmi(prototype, &slow); | 2932 __ BranchOnSmi(prototype, &slow); |
2933 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); | 2933 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); |
2934 | 2934 |
2935 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 2935 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
2936 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); | 2936 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); |
2937 | 2937 |
2938 // Register mapping: r3 is object map and r4 is function prototype. | 2938 // Register mapping: r3 is object map and r4 is function prototype. |
2939 // Get prototype of object into r2. | 2939 // Get prototype of object into r2. |
2940 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); | 2940 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); |
2941 | 2941 |
2942 // Loop through the prototype chain looking for the function prototype. | 2942 // Loop through the prototype chain looking for the function prototype. |
2943 __ bind(&loop); | 2943 __ bind(&loop); |
2944 __ cmp(scratch, Operand(prototype)); | 2944 __ cmp(scratch, Operand(prototype)); |
2945 __ b(eq, &is_instance); | 2945 __ b(eq, &is_instance); |
2946 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 2946 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
2947 __ cmp(scratch, ip); | 2947 __ cmp(scratch, ip); |
2948 __ b(eq, &is_not_instance); | 2948 __ b(eq, &is_not_instance); |
2949 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); | 2949 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
2950 __ ldr(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); | 2950 __ ldr(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); |
2951 __ jmp(&loop); | 2951 __ jmp(&loop); |
2952 | 2952 |
2953 __ bind(&is_instance); | 2953 __ bind(&is_instance); |
2954 __ mov(r0, Operand(Smi::FromInt(0))); | 2954 __ mov(r0, Operand(Smi::FromInt(0))); |
2955 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2955 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); |
2956 __ Ret(args_in_registers() ? 0 : 2); | 2956 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2957 | 2957 |
2958 __ bind(&is_not_instance); | 2958 __ bind(&is_not_instance); |
2959 __ mov(r0, Operand(Smi::FromInt(1))); | 2959 __ mov(r0, Operand(Smi::FromInt(1))); |
2960 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2960 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); |
2961 __ Ret(args_in_registers() ? 0 : 2); | 2961 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2962 | 2962 |
2963 Label object_not_null, object_not_null_or_smi; | 2963 Label object_not_null, object_not_null_or_smi; |
2964 __ bind(¬_js_object); | 2964 __ bind(¬_js_object); |
2965 // Before null, smi and string value checks, check that the rhs is a function | 2965 // Before null, smi and string value checks, check that the rhs is a function |
2966 // as for a non-function rhs an exception needs to be thrown. | 2966 // as for a non-function rhs an exception needs to be thrown. |
2967 __ BranchOnSmi(function, &slow); | 2967 __ BranchOnSmi(function, &slow); |
2968 __ CompareObjectType(function, map, scratch, JS_FUNCTION_TYPE); | 2968 __ CompareObjectType(function, map, scratch, JS_FUNCTION_TYPE); |
2969 __ b(ne, &slow); | 2969 __ b(ne, &slow); |
2970 | 2970 |
2971 // Null is not instance of anything. | 2971 // Null is not instance of anything. |
2972 __ cmp(scratch, Operand(Factory::null_value())); | 2972 __ cmp(scratch, Operand(Factory::null_value())); |
2973 __ b(ne, &object_not_null); | 2973 __ b(ne, &object_not_null); |
2974 __ mov(r0, Operand(Smi::FromInt(1))); | 2974 __ mov(r0, Operand(Smi::FromInt(1))); |
2975 __ Ret(args_in_registers() ? 0 : 2); | 2975 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2976 | 2976 |
2977 __ bind(&object_not_null); | 2977 __ bind(&object_not_null); |
2978 // Smi values are not instances of anything. | 2978 // Smi values are not instances of anything. |
2979 __ BranchOnNotSmi(object, &object_not_null_or_smi); | 2979 __ BranchOnNotSmi(object, &object_not_null_or_smi); |
2980 __ mov(r0, Operand(Smi::FromInt(1))); | 2980 __ mov(r0, Operand(Smi::FromInt(1))); |
2981 __ Ret(args_in_registers() ? 0 : 2); | 2981 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2982 | 2982 |
2983 __ bind(&object_not_null_or_smi); | 2983 __ bind(&object_not_null_or_smi); |
2984 // String values are not instances of anything. | 2984 // String values are not instances of anything. |
2985 __ IsObjectJSStringType(object, scratch, &slow); | 2985 __ IsObjectJSStringType(object, scratch, &slow); |
2986 __ mov(r0, Operand(Smi::FromInt(1))); | 2986 __ mov(r0, Operand(Smi::FromInt(1))); |
2987 __ Ret(args_in_registers() ? 0 : 2); | 2987 __ Ret(HasArgsInRegisters() ? 0 : 2); |
2988 | 2988 |
2989 // Slow-case. Tail call builtin. | 2989 // Slow-case. Tail call builtin. |
2990 if (args_in_registers()) { | 2990 if (HasArgsInRegisters()) { |
2991 __ Push(r0, r1); | 2991 __ Push(r0, r1); |
2992 } | 2992 } |
2993 __ bind(&slow); | 2993 __ bind(&slow); |
2994 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS); | 2994 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS); |
2995 } | 2995 } |
2996 | 2996 |
2997 | 2997 |
2998 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 2998 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
2999 // The displacement is the offset of the last parameter (if any) | 2999 // The displacement is the offset of the last parameter (if any) |
3000 // relative to the frame pointer. | 3000 // relative to the frame pointer. |
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4980 __ pop(r1); | 4980 __ pop(r1); |
4981 __ Jump(r2); | 4981 __ Jump(r2); |
4982 } | 4982 } |
4983 | 4983 |
4984 | 4984 |
4985 #undef __ | 4985 #undef __ |
4986 | 4986 |
4987 } } // namespace v8::internal | 4987 } } // namespace v8::internal |
4988 | 4988 |
4989 #endif // V8_TARGET_ARCH_ARM | 4989 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |