OLD | NEW |
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 2951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 __ CallStub(&stub); | 2962 __ CallStub(&stub); |
2963 context()->Plug(rax); | 2963 context()->Plug(rax); |
2964 } | 2964 } |
2965 | 2965 |
2966 | 2966 |
2967 void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) { | 2967 void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) { |
2968 ASSERT(args->length() == 3); | 2968 ASSERT(args->length() == 3); |
2969 VisitForStackValue(args->at(0)); | 2969 VisitForStackValue(args->at(0)); |
2970 VisitForStackValue(args->at(1)); | 2970 VisitForStackValue(args->at(1)); |
2971 VisitForStackValue(args->at(2)); | 2971 VisitForStackValue(args->at(2)); |
| 2972 Label done; |
| 2973 Label slow_case; |
| 2974 Register object = rax; |
| 2975 Register index_1 = rbx; |
| 2976 Register index_2 = rcx; |
| 2977 Register elements = rdi; |
| 2978 Register temp = rdx; |
| 2979 __ movq(object, Operand(rsp, 2 * kPointerSize)); |
| 2980 // Fetch the map and check if array is in fast case. |
| 2981 // Check that object doesn't require security checks and |
| 2982 // has no indexed interceptor. |
| 2983 __ CmpObjectType(object, FIRST_JS_OBJECT_TYPE, temp); |
| 2984 __ j(below, &slow_case); |
| 2985 __ testb(FieldOperand(temp, Map::kBitFieldOffset), |
| 2986 Immediate(KeyedLoadIC::kSlowCaseBitFieldMask)); |
| 2987 __ j(not_zero, &slow_case); |
| 2988 |
| 2989 // Check the object's elements are in fast case and writable. |
| 2990 __ movq(elements, FieldOperand(object, JSObject::kElementsOffset)); |
| 2991 __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset), |
| 2992 Heap::kFixedArrayMapRootIndex); |
| 2993 __ j(not_equal, &slow_case); |
| 2994 |
| 2995 // Check that both indices are smis. |
| 2996 __ movq(index_1, Operand(rsp, 1 * kPointerSize)); |
| 2997 __ movq(index_2, Operand(rsp, 0 * kPointerSize)); |
| 2998 __ JumpIfNotBothSmi(index_1, index_2, &slow_case); |
| 2999 |
| 3000 // Check that both indices are valid. |
| 3001 // The JSArray length field is a smi since the array is in fast case mode. |
| 3002 __ movq(temp, FieldOperand(object, JSArray::kLengthOffset)); |
| 3003 __ SmiCompare(temp, index_1); |
| 3004 __ j(below_equal, &slow_case); |
| 3005 __ SmiCompare(temp, index_2); |
| 3006 __ j(below_equal, &slow_case); |
| 3007 |
| 3008 __ SmiToInteger32(index_1, index_1); |
| 3009 __ SmiToInteger32(index_2, index_2); |
| 3010 // Bring addresses into index1 and index2. |
| 3011 __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size, |
| 3012 FixedArray::kHeaderSize)); |
| 3013 __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size, |
| 3014 FixedArray::kHeaderSize)); |
| 3015 |
| 3016 // Swap elements. Use object and temp as scratch registers. |
| 3017 __ movq(object, Operand(index_1, 0)); |
| 3018 __ movq(temp, Operand(index_2, 0)); |
| 3019 __ movq(Operand(index_2, 0), object); |
| 3020 __ movq(Operand(index_1, 0), temp); |
| 3021 |
| 3022 Label new_space; |
| 3023 __ InNewSpace(elements, temp, equal, &new_space); |
| 3024 |
| 3025 __ movq(object, elements); |
| 3026 __ RecordWriteHelper(object, index_1, temp); |
| 3027 __ RecordWriteHelper(elements, index_2, temp); |
| 3028 |
| 3029 __ bind(&new_space); |
| 3030 // We are done. Drop elements from the stack, and return undefined. |
| 3031 __ addq(rsp, Immediate(3 * kPointerSize)); |
| 3032 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 3033 __ jmp(&done); |
| 3034 |
| 3035 __ bind(&slow_case); |
2972 __ CallRuntime(Runtime::kSwapElements, 3); | 3036 __ CallRuntime(Runtime::kSwapElements, 3); |
| 3037 |
| 3038 __ bind(&done); |
2973 context()->Plug(rax); | 3039 context()->Plug(rax); |
2974 } | 3040 } |
2975 | 3041 |
2976 | 3042 |
2977 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { | 3043 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { |
2978 ASSERT_EQ(2, args->length()); | 3044 ASSERT_EQ(2, args->length()); |
2979 | 3045 |
2980 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3046 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
2981 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3047 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
2982 | 3048 |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3879 __ ret(0); | 3945 __ ret(0); |
3880 } | 3946 } |
3881 | 3947 |
3882 | 3948 |
3883 #undef __ | 3949 #undef __ |
3884 | 3950 |
3885 | 3951 |
3886 } } // namespace v8::internal | 3952 } } // namespace v8::internal |
3887 | 3953 |
3888 #endif // V8_TARGET_ARCH_X64 | 3954 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |