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

Side by Side Diff: src/mips/full-codegen-mips.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 | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime.h » ('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 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3389 ZoneList<Expression*>* args = expr->arguments(); 3389 ZoneList<Expression*>* args = expr->arguments();
3390 ASSERT(args->length() == 3); 3390 ASSERT(args->length() == 3);
3391 VisitForStackValue(args->at(0)); 3391 VisitForStackValue(args->at(0));
3392 VisitForStackValue(args->at(1)); 3392 VisitForStackValue(args->at(1));
3393 VisitForStackValue(args->at(2)); 3393 VisitForStackValue(args->at(2));
3394 __ CallStub(&stub); 3394 __ CallStub(&stub);
3395 context()->Plug(v0); 3395 context()->Plug(v0);
3396 } 3396 }
3397 3397
3398 3398
3399 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3400 ZoneList<Expression*>* args = expr->arguments();
3401 ASSERT(args->length() == 3);
3402 VisitForStackValue(args->at(0));
3403 VisitForStackValue(args->at(1));
3404 VisitForStackValue(args->at(2));
3405 Label done;
3406 Label slow_case;
3407 Register object = a0;
3408 Register index1 = a1;
3409 Register index2 = a2;
3410 Register elements = a3;
3411 Register scratch1 = t0;
3412 Register scratch2 = t1;
3413
3414 __ lw(object, MemOperand(sp, 2 * kPointerSize));
3415 // Fetch the map and check if array is in fast case.
3416 // Check that object doesn't require security checks and
3417 // has no indexed interceptor.
3418 __ GetObjectType(object, scratch1, scratch2);
3419 __ Branch(&slow_case, ne, scratch2, Operand(JS_ARRAY_TYPE));
3420 // Map is now in scratch1.
3421
3422 __ lbu(scratch2, FieldMemOperand(scratch1, Map::kBitFieldOffset));
3423 __ And(scratch2, scratch2, Operand(KeyedLoadIC::kSlowCaseBitFieldMask));
3424 __ Branch(&slow_case, ne, scratch2, Operand(zero_reg));
3425
3426 // Check the object's elements are in fast case and writable.
3427 __ lw(elements, FieldMemOperand(object, JSObject::kElementsOffset));
3428 __ lw(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
3429 __ LoadRoot(scratch2, Heap::kFixedArrayMapRootIndex);
3430 __ Branch(&slow_case, ne, scratch1, Operand(scratch2));
3431
3432 // Check that both indices are smis.
3433 __ lw(index1, MemOperand(sp, 1 * kPointerSize));
3434 __ lw(index2, MemOperand(sp, 0));
3435 __ JumpIfNotBothSmi(index1, index2, &slow_case);
3436
3437 // Check that both indices are valid.
3438 Label not_hi;
3439 __ lw(scratch1, FieldMemOperand(object, JSArray::kLengthOffset));
3440 __ Branch(&slow_case, ls, scratch1, Operand(index1));
3441 __ Branch(&not_hi, NegateCondition(hi), scratch1, Operand(index1));
3442 __ Branch(&slow_case, ls, scratch1, Operand(index2));
3443 __ bind(&not_hi);
3444
3445 // Bring the address of the elements into index1 and index2.
3446 __ Addu(scratch1, elements,
3447 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3448 __ sll(index1, index1, kPointerSizeLog2 - kSmiTagSize);
3449 __ Addu(index1, scratch1, index1);
3450 __ sll(index2, index2, kPointerSizeLog2 - kSmiTagSize);
3451 __ Addu(index2, scratch1, index2);
3452
3453 // Swap elements.
3454 __ lw(scratch1, MemOperand(index1, 0));
3455 __ lw(scratch2, MemOperand(index2, 0));
3456 __ sw(scratch1, MemOperand(index2, 0));
3457 __ sw(scratch2, MemOperand(index1, 0));
3458
3459 Label no_remembered_set;
3460 __ CheckPageFlag(elements,
3461 scratch1,
3462 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3463 ne,
3464 &no_remembered_set);
3465 // Possible optimization: do a check that both values are Smis
3466 // (or them and test against Smi mask).
3467
3468 // We are swapping two objects in an array and the incremental marker never
3469 // pauses in the middle of scanning a single object. Therefore the
3470 // incremental marker is not disturbed, so we don't need to call the
3471 // RecordWrite stub that notifies the incremental marker.
3472 __ RememberedSetHelper(elements,
3473 index1,
3474 scratch2,
3475 kDontSaveFPRegs,
3476 MacroAssembler::kFallThroughAtEnd);
3477 __ RememberedSetHelper(elements,
3478 index2,
3479 scratch2,
3480 kDontSaveFPRegs,
3481 MacroAssembler::kFallThroughAtEnd);
3482
3483 __ bind(&no_remembered_set);
3484 // We are done. Drop elements from the stack, and return undefined.
3485 __ Drop(3);
3486 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
3487 __ jmp(&done);
3488
3489 __ bind(&slow_case);
3490 __ CallRuntime(Runtime::kSwapElements, 3);
3491
3492 __ bind(&done);
3493 context()->Plug(v0);
3494 }
3495
3496
3497 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3399 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3498 ZoneList<Expression*>* args = expr->arguments(); 3400 ZoneList<Expression*>* args = expr->arguments();
3499 ASSERT_EQ(2, args->length()); 3401 ASSERT_EQ(2, args->length());
3500 3402
3501 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3403 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3502 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3404 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3503 3405
3504 Handle<FixedArray> jsfunction_result_caches( 3406 Handle<FixedArray> jsfunction_result_caches(
3505 isolate()->global_context()->jsfunction_result_caches()); 3407 isolate()->global_context()->jsfunction_result_caches());
3506 if (jsfunction_result_caches->length() <= cache_id) { 3408 if (jsfunction_result_caches->length() <= cache_id) {
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
4565 *context_length = 0; 4467 *context_length = 0;
4566 return previous_; 4468 return previous_;
4567 } 4469 }
4568 4470
4569 4471
4570 #undef __ 4472 #undef __
4571 4473
4572 } } // namespace v8::internal 4474 } } // namespace v8::internal
4573 4475
4574 #endif // V8_TARGET_ARCH_MIPS 4476 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698