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

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

Issue 10332271: Fix prepareElementsForSort crash bug=117879. This is a back (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.9/
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 | « no previous file | src/array.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 ZoneList<Expression*>* args = expr->arguments(); 3355 ZoneList<Expression*>* args = expr->arguments();
3356 ASSERT(args->length() == 3); 3356 ASSERT(args->length() == 3);
3357 VisitForStackValue(args->at(0)); 3357 VisitForStackValue(args->at(0));
3358 VisitForStackValue(args->at(1)); 3358 VisitForStackValue(args->at(1));
3359 VisitForStackValue(args->at(2)); 3359 VisitForStackValue(args->at(2));
3360 __ CallStub(&stub); 3360 __ CallStub(&stub);
3361 context()->Plug(r0); 3361 context()->Plug(r0);
3362 } 3362 }
3363 3363
3364 3364
3365 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3366 ZoneList<Expression*>* args = expr->arguments();
3367 ASSERT(args->length() == 3);
3368 VisitForStackValue(args->at(0));
3369 VisitForStackValue(args->at(1));
3370 VisitForStackValue(args->at(2));
3371 Label done;
3372 Label slow_case;
3373 Register object = r0;
3374 Register index1 = r1;
3375 Register index2 = r2;
3376 Register elements = r3;
3377 Register scratch1 = r4;
3378 Register scratch2 = r5;
3379
3380 __ ldr(object, MemOperand(sp, 2 * kPointerSize));
3381 // Fetch the map and check if array is in fast case.
3382 // Check that object doesn't require security checks and
3383 // has no indexed interceptor.
3384 __ CompareObjectType(object, scratch1, scratch2, JS_ARRAY_TYPE);
3385 __ b(ne, &slow_case);
3386 // Map is now in scratch1.
3387
3388 __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitFieldOffset));
3389 __ tst(scratch2, Operand(KeyedLoadIC::kSlowCaseBitFieldMask));
3390 __ b(ne, &slow_case);
3391
3392 // Check the object's elements are in fast case and writable.
3393 __ ldr(elements, FieldMemOperand(object, JSObject::kElementsOffset));
3394 __ ldr(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
3395 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex);
3396 __ cmp(scratch1, ip);
3397 __ b(ne, &slow_case);
3398
3399 // Check that both indices are smis.
3400 __ ldr(index1, MemOperand(sp, 1 * kPointerSize));
3401 __ ldr(index2, MemOperand(sp, 0));
3402 __ JumpIfNotBothSmi(index1, index2, &slow_case);
3403
3404 // Check that both indices are valid.
3405 __ ldr(scratch1, FieldMemOperand(object, JSArray::kLengthOffset));
3406 __ cmp(scratch1, index1);
3407 __ cmp(scratch1, index2, hi);
3408 __ b(ls, &slow_case);
3409
3410 // Bring the address of the elements into index1 and index2.
3411 __ add(scratch1, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3412 __ add(index1,
3413 scratch1,
3414 Operand(index1, LSL, kPointerSizeLog2 - kSmiTagSize));
3415 __ add(index2,
3416 scratch1,
3417 Operand(index2, LSL, kPointerSizeLog2 - kSmiTagSize));
3418
3419 // Swap elements.
3420 __ ldr(scratch1, MemOperand(index1, 0));
3421 __ ldr(scratch2, MemOperand(index2, 0));
3422 __ str(scratch1, MemOperand(index2, 0));
3423 __ str(scratch2, MemOperand(index1, 0));
3424
3425 Label no_remembered_set;
3426 __ CheckPageFlag(elements,
3427 scratch1,
3428 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3429 ne,
3430 &no_remembered_set);
3431 // Possible optimization: do a check that both values are Smis
3432 // (or them and test against Smi mask.)
3433
3434 // We are swapping two objects in an array and the incremental marker never
3435 // pauses in the middle of scanning a single object. Therefore the
3436 // incremental marker is not disturbed, so we don't need to call the
3437 // RecordWrite stub that notifies the incremental marker.
3438 __ RememberedSetHelper(elements,
3439 index1,
3440 scratch2,
3441 kDontSaveFPRegs,
3442 MacroAssembler::kFallThroughAtEnd);
3443 __ RememberedSetHelper(elements,
3444 index2,
3445 scratch2,
3446 kDontSaveFPRegs,
3447 MacroAssembler::kFallThroughAtEnd);
3448
3449 __ bind(&no_remembered_set);
3450 // We are done. Drop elements from the stack, and return undefined.
3451 __ Drop(3);
3452 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
3453 __ jmp(&done);
3454
3455 __ bind(&slow_case);
3456 __ CallRuntime(Runtime::kSwapElements, 3);
3457
3458 __ bind(&done);
3459 context()->Plug(r0);
3460 }
3461
3462
3463 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3365 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3464 ZoneList<Expression*>* args = expr->arguments(); 3366 ZoneList<Expression*>* args = expr->arguments();
3465 ASSERT_EQ(2, args->length()); 3367 ASSERT_EQ(2, args->length());
3466 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3368 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3467 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3369 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3468 3370
3469 Handle<FixedArray> jsfunction_result_caches( 3371 Handle<FixedArray> jsfunction_result_caches(
3470 isolate()->global_context()->jsfunction_result_caches()); 3372 isolate()->global_context()->jsfunction_result_caches());
3471 if (jsfunction_result_caches->length() <= cache_id) { 3373 if (jsfunction_result_caches->length() <= cache_id) {
3472 __ Abort("Attempt to use undefined cache."); 3374 __ Abort("Attempt to use undefined cache.");
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 *context_length = 0; 4430 *context_length = 0;
4529 return previous_; 4431 return previous_;
4530 } 4432 }
4531 4433
4532 4434
4533 #undef __ 4435 #undef __
4534 4436
4535 } } // namespace v8::internal 4437 } } // namespace v8::internal
4536 4438
4537 #endif // V8_TARGET_ARCH_ARM 4439 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698