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 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3106 __ CallStub(&stub); | 3106 __ CallStub(&stub); |
3107 context()->Plug(r0); | 3107 context()->Plug(r0); |
3108 } | 3108 } |
3109 | 3109 |
3110 | 3110 |
3111 void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) { | 3111 void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) { |
3112 ASSERT(args->length() == 3); | 3112 ASSERT(args->length() == 3); |
3113 VisitForStackValue(args->at(0)); | 3113 VisitForStackValue(args->at(0)); |
3114 VisitForStackValue(args->at(1)); | 3114 VisitForStackValue(args->at(1)); |
3115 VisitForStackValue(args->at(2)); | 3115 VisitForStackValue(args->at(2)); |
3116 Label done; | |
3117 Label slow_case; | |
3118 Register object = r0; | |
3119 Register index1 = r1; | |
3120 Register index2 = r2; | |
3121 Register elements = r3; | |
3122 Register scratch1 = r4; | |
3123 Register scratch2 = r5; | |
3124 | |
3125 __ ldr(object, MemOperand(sp, 2 * kPointerSize)); | |
3126 // Fetch the map and check if array is in fast case. | |
3127 // Check that object doesn't require security checks and | |
3128 // has no indexed interceptor. | |
3129 __ CompareObjectType(object, scratch1, scratch2, FIRST_JS_OBJECT_TYPE); | |
3130 __ b(lt, &slow_case); | |
3131 // Map is now in scratch1. | |
3132 | |
3133 __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitFieldOffset)); | |
3134 __ tst(scratch2, Operand(KeyedLoadIC::kSlowCaseBitFieldMask)); | |
3135 __ b(ne, &slow_case); | |
3136 | |
3137 // Check the object's elements are in fast case and writable. | |
Karl Klose
2011/03/02 15:04:39
What does writable mean here?
Søren Thygesen Gjesse
2011/03/03 07:34:31
It means that it is not copy-on-write (copy-on-wri
| |
3138 __ ldr(elements, FieldMemOperand(object, JSObject::kElementsOffset)); | |
3139 __ ldr(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
3140 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); | |
3141 __ cmp(scratch1, ip); | |
3142 __ b(ne, &slow_case); | |
3143 | |
3144 // Check that both indices are smis. | |
3145 __ ldr(index1, MemOperand(sp, 1 * kPointerSize)); | |
3146 __ ldr(index2, MemOperand(sp, 0)); | |
3147 __ JumpIfNotBothSmi(index1, index2, &slow_case); | |
3148 | |
3149 // Check that both indices are valid. | |
3150 __ ldr(scratch1, FieldMemOperand(object, JSArray::kLengthOffset)); | |
3151 __ cmp(scratch1, index1); | |
3152 __ cmp(scratch1, index2, hi); | |
3153 __ b(ls, &slow_case); | |
3154 | |
3155 // Bring the address of the elements into index1 and index2. | |
3156 __ add(scratch1, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
3157 __ add(index1, | |
3158 scratch1, | |
3159 Operand(index1, LSL, kPointerSizeLog2 - kSmiTagSize)); | |
3160 __ add(index2, | |
3161 scratch1, | |
3162 Operand(index2, LSL, kPointerSizeLog2 - kSmiTagSize)); | |
3163 | |
3164 // Swap elements. | |
3165 __ ldr(scratch1, MemOperand(index1, 0)); | |
3166 __ ldr(scratch2, MemOperand(index2, 0))); | |
3167 __ str(scratch1, MemOperand(index2, 0)); | |
3168 __ str(scratch2, MemOperand(index1, 0)); | |
3169 | |
3170 Label new_space; | |
3171 __ InNewSpace(elements, scratch1, eq, &new_space); | |
3172 // Possible optimization: do a check that both values are Smis | |
3173 // (or them and test against Smi mask.) | |
3174 | |
3175 __ mov(scratch1, elements); | |
3176 __ RecordWriteHelper(elements, index1, scratch2); | |
3177 __ RecordWriteHelper(scratch1, index2, scratch2); // scratch1 holds elements. | |
3178 __ bind(&done); | |
3179 | |
3180 __ bind(&new_space); | |
3181 // We are done. Drop elements from the stack, and return undefined. | |
3182 __ Drop(3); | |
3183 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | |
3184 __ jmp(&done); | |
3185 | |
3186 __ bind(&slow_case); | |
3116 __ CallRuntime(Runtime::kSwapElements, 3); | 3187 __ CallRuntime(Runtime::kSwapElements, 3); |
3188 | |
3189 __ bind(&done); | |
3117 context()->Plug(r0); | 3190 context()->Plug(r0); |
3118 } | 3191 } |
3119 | 3192 |
3120 | 3193 |
3121 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { | 3194 void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) { |
3122 ASSERT_EQ(2, args->length()); | 3195 ASSERT_EQ(2, args->length()); |
3123 | 3196 |
3124 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3197 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
3125 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3198 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
3126 | 3199 |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4224 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4297 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
4225 __ add(pc, r1, Operand(masm_->CodeObject())); | 4298 __ add(pc, r1, Operand(masm_->CodeObject())); |
4226 } | 4299 } |
4227 | 4300 |
4228 | 4301 |
4229 #undef __ | 4302 #undef __ |
4230 | 4303 |
4231 } } // namespace v8::internal | 4304 } } // namespace v8::internal |
4232 | 4305 |
4233 #endif // V8_TARGET_ARCH_ARM | 4306 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |