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 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2961 VisitForStackValue(args->at(2)); | 2961 VisitForStackValue(args->at(2)); |
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)); |
Lasse Reichstein
2011/03/01 14:01:50
Could we put the values directly into registers, a
William Hesse
2011/03/01 14:29:52
This is a direct copy of ia32 code, where there is
| |
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)); | |
Lasse Reichstein
2011/03/01 14:01:50
Mutiply by kPointerSize here too, just for consist
William Hesse
2011/03/01 14:29:52
Done.
| |
2998 __ JumpIfNotBothSmi(index_1, index_2, &slow_case); | |
2999 | |
3000 // Check that both indices are valid. | |
3001 __ movq(temp, FieldOperand(object, JSArray::kLengthOffset)); | |
Lasse Reichstein
2011/03/01 14:01:50
Make a comment that since the array is in fast ele
William Hesse
2011/03/01 14:29:52
Done.
Yes, it is always a smi.
| |
3002 __ SmiCompare(temp, index_1); | |
3003 __ j(below_equal, &slow_case); | |
3004 __ SmiCompare(temp, index_2); | |
3005 __ j(below_equal, &slow_case); | |
3006 | |
3007 __ SmiToInteger32(index_1, index_1); | |
3008 __ SmiToInteger32(index_2, index_2); | |
3009 // Bring addresses into index1 and index2. | |
3010 __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size, | |
3011 FixedArray::kHeaderSize)); | |
3012 __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size, | |
3013 FixedArray::kHeaderSize)); | |
3014 | |
3015 // Swap elements. Use object and temp as scratch registers. | |
3016 __ movq(object, Operand(index_1, 0)); | |
3017 __ movq(temp, Operand(index_2, 0)); | |
3018 __ movq(Operand(index_2, 0), object); | |
3019 __ movq(Operand(index_1, 0), temp); | |
3020 | |
3021 Label new_space; | |
3022 __ InNewSpace(elements, temp, equal, &new_space); | |
3023 | |
3024 __ movq(object, elements); | |
3025 __ RecordWriteHelper(object, index_1, temp); | |
3026 __ RecordWriteHelper(elements, index_2, temp); | |
3027 | |
3028 __ bind(&new_space); | |
3029 // We are done. Drop elements from the stack, and return undefined. | |
3030 __ addq(rsp, Immediate(3 * kPointerSize)); | |
3031 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | |
3032 __ jmp(&done); | |
3033 | |
3034 __ bind(&slow_case); | |
2972 __ CallRuntime(Runtime::kSwapElements, 3); | 3035 __ CallRuntime(Runtime::kSwapElements, 3); |
3036 | |
3037 __ bind(&done); | |
2973 context()->Plug(rax); | 3038 context()->Plug(rax); |
2974 } | 3039 } |
2975 | 3040 |
2976 | 3041 |
2977 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { | 3042 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { |
2978 ASSERT_EQ(2, args->length()); | 3043 ASSERT_EQ(2, args->length()); |
2979 | 3044 |
2980 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3045 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
2981 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3046 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
2982 | 3047 |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3879 __ ret(0); | 3944 __ ret(0); |
3880 } | 3945 } |
3881 | 3946 |
3882 | 3947 |
3883 #undef __ | 3948 #undef __ |
3884 | 3949 |
3885 | 3950 |
3886 } } // namespace v8::internal | 3951 } } // namespace v8::internal |
3887 | 3952 |
3888 #endif // V8_TARGET_ARCH_X64 | 3953 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |