Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 10413030: Fix prepareElementsForSort crash bug=117879 . This is a back (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.8/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 ZoneList<Expression*>* args = expr->arguments(); 3169 ZoneList<Expression*>* args = expr->arguments();
3170 ASSERT(args->length() == 3); 3170 ASSERT(args->length() == 3);
3171 VisitForStackValue(args->at(0)); 3171 VisitForStackValue(args->at(0));
3172 VisitForStackValue(args->at(1)); 3172 VisitForStackValue(args->at(1));
3173 VisitForStackValue(args->at(2)); 3173 VisitForStackValue(args->at(2));
3174 __ CallStub(&stub); 3174 __ CallStub(&stub);
3175 context()->Plug(eax); 3175 context()->Plug(eax);
3176 } 3176 }
3177 3177
3178 3178
3179 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3180 ZoneList<Expression*>* args = expr->arguments();
3181 ASSERT(args->length() == 3);
3182 VisitForStackValue(args->at(0));
3183 VisitForStackValue(args->at(1));
3184 VisitForStackValue(args->at(2));
3185 Label done;
3186 Label slow_case;
3187 Register object = eax;
3188 Register index_1 = ebx;
3189 Register index_2 = ecx;
3190 Register elements = edi;
3191 Register temp = edx;
3192 __ mov(object, Operand(esp, 2 * kPointerSize));
3193 // Fetch the map and check if array is in fast case.
3194 // Check that object doesn't require security checks and
3195 // has no indexed interceptor.
3196 __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3197 __ j(not_equal, &slow_case);
3198 __ test_b(FieldOperand(temp, Map::kBitFieldOffset),
3199 KeyedLoadIC::kSlowCaseBitFieldMask);
3200 __ j(not_zero, &slow_case);
3201
3202 // Check the object's elements are in fast case and writable.
3203 __ mov(elements, FieldOperand(object, JSObject::kElementsOffset));
3204 __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
3205 Immediate(isolate()->factory()->fixed_array_map()));
3206 __ j(not_equal, &slow_case);
3207
3208 // Check that both indices are smis.
3209 __ mov(index_1, Operand(esp, 1 * kPointerSize));
3210 __ mov(index_2, Operand(esp, 0));
3211 __ mov(temp, index_1);
3212 __ or_(temp, index_2);
3213 __ JumpIfNotSmi(temp, &slow_case);
3214
3215 // Check that both indices are valid.
3216 __ mov(temp, FieldOperand(object, JSArray::kLengthOffset));
3217 __ cmp(temp, index_1);
3218 __ j(below_equal, &slow_case);
3219 __ cmp(temp, index_2);
3220 __ j(below_equal, &slow_case);
3221
3222 // Bring addresses into index1 and index2.
3223 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1));
3224 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2));
3225
3226 // Swap elements. Use object and temp as scratch registers.
3227 __ mov(object, Operand(index_1, 0));
3228 __ mov(temp, Operand(index_2, 0));
3229 __ mov(Operand(index_2, 0), object);
3230 __ mov(Operand(index_1, 0), temp);
3231
3232 Label no_remembered_set;
3233 __ CheckPageFlag(elements,
3234 temp,
3235 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3236 not_zero,
3237 &no_remembered_set,
3238 Label::kNear);
3239 // Possible optimization: do a check that both values are Smis
3240 // (or them and test against Smi mask.)
3241
3242 // We are swapping two objects in an array and the incremental marker never
3243 // pauses in the middle of scanning a single object. Therefore the
3244 // incremental marker is not disturbed, so we don't need to call the
3245 // RecordWrite stub that notifies the incremental marker.
3246 __ RememberedSetHelper(elements,
3247 index_1,
3248 temp,
3249 kDontSaveFPRegs,
3250 MacroAssembler::kFallThroughAtEnd);
3251 __ RememberedSetHelper(elements,
3252 index_2,
3253 temp,
3254 kDontSaveFPRegs,
3255 MacroAssembler::kFallThroughAtEnd);
3256
3257 __ bind(&no_remembered_set);
3258
3259 // We are done. Drop elements from the stack, and return undefined.
3260 __ add(esp, Immediate(3 * kPointerSize));
3261 __ mov(eax, isolate()->factory()->undefined_value());
3262 __ jmp(&done);
3263
3264 __ bind(&slow_case);
3265 __ CallRuntime(Runtime::kSwapElements, 3);
3266
3267 __ bind(&done);
3268 context()->Plug(eax);
3269 }
3270
3271
3272 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3179 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3273 ZoneList<Expression*>* args = expr->arguments(); 3180 ZoneList<Expression*>* args = expr->arguments();
3274 ASSERT_EQ(2, args->length()); 3181 ASSERT_EQ(2, args->length());
3275 3182
3276 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3183 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3277 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3184 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3278 3185
3279 Handle<FixedArray> jsfunction_result_caches( 3186 Handle<FixedArray> jsfunction_result_caches(
3280 isolate()->global_context()->jsfunction_result_caches()); 3187 isolate()->global_context()->jsfunction_result_caches());
3281 if (jsfunction_result_caches->length() <= cache_id) { 3188 if (jsfunction_result_caches->length() <= cache_id) {
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 *context_length = 0; 4287 *context_length = 0;
4381 return previous_; 4288 return previous_;
4382 } 4289 }
4383 4290
4384 4291
4385 #undef __ 4292 #undef __
4386 4293
4387 } } // namespace v8::internal 4294 } } // namespace v8::internal
4388 4295
4389 #endif // V8_TARGET_ARCH_IA32 4296 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698