Chromium Code Reviews| 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 r5. 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 const Register scratch2 = r5; // Used for IncrementCounter. | |
| 2908 const Register result = r0; | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
I don't think an alias for the result is required
| |
| 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 } | |
| 2914 __ BranchOnSmi(function, &slow); | |
| 2905 | 2915 |
| 2906 // Check that the left hand is a JS object and put map in r3. | 2916 // Check that the left hand is a JS object, load map, |
| 2907 __ CompareObjectType(r0, r3, r2, FIRST_JS_OBJECT_TYPE); | 2917 // and type into scratch |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
How about implementing IsObjectJSObjectType in the
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 2918 __ CompareObjectType(function, map, scratch, FIRST_JS_OBJECT_TYPE); | |
| 2908 __ b(lt, &slow); | 2919 __ b(lt, &slow); |
| 2909 __ cmp(r2, Operand(LAST_JS_OBJECT_TYPE)); | 2920 __ cmp(scratch, Operand(LAST_JS_OBJECT_TYPE)); |
| 2910 __ b(gt, &slow); | 2921 __ b(gt, &slow); |
| 2911 | 2922 |
| 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 // Look up the function and the map in the instanceof cache. | 2923 // Look up the function and the map in the instanceof cache. |
| 2917 Label miss; | 2924 Label miss; |
| 2918 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex); | 2925 __ LoadRoot(ip, Heap::kInstanceofCacheFunctionRootIndex); |
| 2919 __ cmp(r1, ip); | 2926 __ cmp(object, ip); |
| 2920 __ b(ne, &miss); | 2927 __ b(ne, &miss); |
| 2921 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex); | 2928 __ LoadRoot(ip, Heap::kInstanceofCacheMapRootIndex); |
| 2922 __ cmp(r3, ip); | 2929 __ cmp(map, ip); |
| 2923 __ b(ne, &miss); | 2930 __ b(ne, &miss); |
| 2924 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2931 __ LoadRoot(function, Heap::kInstanceofCacheAnswerRootIndex); |
| 2925 __ pop(); | 2932 if (!args_in_registers()) { |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
Use Drop from the ARM macro assembler to drop two
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 2926 __ pop(); | 2933 __ pop(); |
| 2934 __ pop(); | |
| 2935 } | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
Use Ret from the ARM macro assembler. I suggest yo
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 2927 __ mov(pc, Operand(lr)); | 2936 __ mov(pc, Operand(lr)); |
| 2928 | 2937 |
| 2929 __ bind(&miss); | 2938 __ bind(&miss); |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
You should use the register aliases created throug
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 2930 __ TryGetFunctionPrototype(r1, r4, r2, &slow); | 2939 __ TryGetFunctionPrototype(r1, r4, r2, &slow); |
| 2931 | 2940 |
| 2932 // Check that the function prototype is a JS object. | 2941 // Check that the function prototype is a JS object. |
| 2933 __ BranchOnSmi(r4, &slow); | 2942 __ BranchOnSmi(r4, &slow); |
| 2934 __ CompareObjectType(r4, r5, r5, FIRST_JS_OBJECT_TYPE); | 2943 __ CompareObjectType(r4, r5, r5, FIRST_JS_OBJECT_TYPE); |
| 2935 __ b(lt, &slow); | 2944 __ b(lt, &slow); |
| 2936 __ cmp(r5, Operand(LAST_JS_OBJECT_TYPE)); | 2945 __ cmp(r5, Operand(LAST_JS_OBJECT_TYPE)); |
| 2937 __ b(gt, &slow); | 2946 __ b(gt, &slow); |
| 2938 | 2947 |
| 2939 __ StoreRoot(r1, Heap::kInstanceofCacheFunctionRootIndex); | 2948 __ StoreRoot(r1, Heap::kInstanceofCacheFunctionRootIndex); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2950 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 2959 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 2951 __ cmp(r2, ip); | 2960 __ cmp(r2, ip); |
| 2952 __ b(eq, &is_not_instance); | 2961 __ b(eq, &is_not_instance); |
| 2953 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); | 2962 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); |
| 2954 __ ldr(r2, FieldMemOperand(r2, Map::kPrototypeOffset)); | 2963 __ ldr(r2, FieldMemOperand(r2, Map::kPrototypeOffset)); |
| 2955 __ jmp(&loop); | 2964 __ jmp(&loop); |
| 2956 | 2965 |
| 2957 __ bind(&is_instance); | 2966 __ bind(&is_instance); |
| 2958 __ mov(r0, Operand(Smi::FromInt(0))); | 2967 __ mov(r0, Operand(Smi::FromInt(0))); |
| 2959 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2968 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); |
| 2960 __ pop(); | 2969 if (!args_in_registers()) { |
| 2961 __ pop(); | 2970 __ pop(); |
| 2971 __ pop(); | |
| 2972 } | |
| 2962 __ mov(pc, Operand(lr)); // Return. | 2973 __ mov(pc, Operand(lr)); // Return. |
| 2963 | 2974 |
| 2964 __ bind(&is_not_instance); | 2975 __ bind(&is_not_instance); |
| 2965 __ mov(r0, Operand(Smi::FromInt(1))); | 2976 __ mov(r0, Operand(Smi::FromInt(1))); |
| 2966 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 2977 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); |
| 2967 __ pop(); | 2978 if (!args_in_registers()) { |
| 2968 __ pop(); | 2979 __ pop(); |
| 2980 __ pop(); | |
| 2981 } | |
| 2969 __ mov(pc, Operand(lr)); // Return. | 2982 __ mov(pc, Operand(lr)); // Return. |
| 2970 | 2983 |
| 2984 Label object_not_null, object_not_null_or_smi; | |
| 2985 __ bind(¬_js_object); | |
| 2986 // Before null, smi and string value checks, check that the rhs is a function | |
| 2987 // as for a non-function rhs an exception needs to be thrown. | |
| 2988 __ tst(function, Operand(kSmiTagMask)); | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
The ARM macro assembler has BranchOnSmi.
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 2989 __ b(eq, &slow); | |
| 2990 __ CompareObjectType(function, map, scratch, JS_FUNCTION_TYPE); | |
| 2991 __ b(ne, &slow); | |
| 2992 | |
| 2993 // Null is not instance of anything. | |
| 2994 __ cmp(scratch, Operand(Factory::null_value())); | |
| 2995 __ b(ne, &object_not_null); | |
| 2996 __ mov(result, Operand(Smi::FromInt(1))); | |
| 2997 if (!args_in_registers()) { | |
| 2998 __ pop(); | |
| 2999 __ pop(); | |
| 3000 } | |
| 3001 __ mov(pc, Operand(lr)); // return | |
| 3002 | |
| 3003 __ bind(&object_not_null); | |
| 3004 // Smi values are not instances of anything. | |
| 3005 __ tst(object, Operand(kSmiTagMask)); | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
The ARM macro assembler has BranchOnNotSmi.
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 3006 __ b(nz, &object_not_null_or_smi); | |
| 3007 __ mov(result, Operand(Smi::FromInt(1))); | |
| 3008 if (!args_in_registers()) { | |
| 3009 __ pop(); | |
| 3010 __ pop(); | |
| 3011 } | |
| 3012 __ mov(pc, Operand(lr)); // return | |
| 3013 | |
| 3014 __ bind(&object_not_null_or_smi); | |
| 3015 // String values are not instances of anything. | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
Please implement IsObjectStringType in ARM macro a
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 3016 __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | |
| 3017 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | |
| 3018 ASSERT(kNotStringTag != 0); | |
| 3019 __ tst(scratch, Operand(kIsNotStringMask)); | |
| 3020 __ b(nz, &slow); | |
| 3021 __ IncrementCounter(&Counters::instance_of_stub_false_string, | |
|
Søren Thygesen Gjesse
2010/12/20 13:03:25
You can leave out all the counters. Then you don't
Karl Klose
2010/12/21 08:56:37
Done.
| |
| 3022 1, | |
| 3023 scratch, | |
| 3024 scratch2); | |
| 3025 | |
| 3026 __ mov(result, Operand(Smi::FromInt(1))); | |
| 3027 if (!args_in_registers()) { | |
| 3028 __ pop(); | |
| 3029 __ pop(); | |
| 3030 } | |
| 3031 __ mov(pc, Operand(lr)); // return | |
| 3032 | |
| 2971 // Slow-case. Tail call builtin. | 3033 // Slow-case. Tail call builtin. |
| 2972 __ bind(&slow); | 3034 __ bind(&slow); |
| 2973 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS); | 3035 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_JS); |
| 2974 } | 3036 } |
| 2975 | 3037 |
| 2976 | 3038 |
| 2977 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 3039 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
| 2978 // The displacement is the offset of the last parameter (if any) | 3040 // The displacement is the offset of the last parameter (if any) |
| 2979 // relative to the frame pointer. | 3041 // relative to the frame pointer. |
| 2980 static const int kDisplacement = | 3042 static const int kDisplacement = |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4959 __ pop(r1); | 5021 __ pop(r1); |
| 4960 __ Jump(r2); | 5022 __ Jump(r2); |
| 4961 } | 5023 } |
| 4962 | 5024 |
| 4963 | 5025 |
| 4964 #undef __ | 5026 #undef __ |
| 4965 | 5027 |
| 4966 } } // namespace v8::internal | 5028 } } // namespace v8::internal |
| 4967 | 5029 |
| 4968 #endif // V8_TARGET_ARCH_ARM | 5030 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |