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

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

Issue 10392150: Remove %_SwapElements. This inlined runtime contained an optimization that was dangerous in the pr… (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/runtime.cc ('k') | no next file » | 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 3342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3353 ZoneList<Expression*>* args = expr->arguments(); 3353 ZoneList<Expression*>* args = expr->arguments();
3354 ASSERT(args->length() == 3); 3354 ASSERT(args->length() == 3);
3355 VisitForStackValue(args->at(0)); 3355 VisitForStackValue(args->at(0));
3356 VisitForStackValue(args->at(1)); 3356 VisitForStackValue(args->at(1));
3357 VisitForStackValue(args->at(2)); 3357 VisitForStackValue(args->at(2));
3358 __ CallStub(&stub); 3358 __ CallStub(&stub);
3359 context()->Plug(rax); 3359 context()->Plug(rax);
3360 } 3360 }
3361 3361
3362 3362
3363 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3364 ZoneList<Expression*>* args = expr->arguments();
3365 ASSERT(args->length() == 3);
3366 VisitForStackValue(args->at(0));
3367 VisitForStackValue(args->at(1));
3368 VisitForStackValue(args->at(2));
3369 Label done;
3370 Label slow_case;
3371 Register object = rax;
3372 Register index_1 = rbx;
3373 Register index_2 = rcx;
3374 Register elements = rdi;
3375 Register temp = rdx;
3376 __ movq(object, Operand(rsp, 2 * kPointerSize));
3377 // Fetch the map and check if array is in fast case.
3378 // Check that object doesn't require security checks and
3379 // has no indexed interceptor.
3380 __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3381 __ j(not_equal, &slow_case);
3382 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
3383 Immediate(KeyedLoadIC::kSlowCaseBitFieldMask));
3384 __ j(not_zero, &slow_case);
3385
3386 // Check the object's elements are in fast case and writable.
3387 __ movq(elements, FieldOperand(object, JSObject::kElementsOffset));
3388 __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
3389 Heap::kFixedArrayMapRootIndex);
3390 __ j(not_equal, &slow_case);
3391
3392 // Check that both indices are smis.
3393 __ movq(index_1, Operand(rsp, 1 * kPointerSize));
3394 __ movq(index_2, Operand(rsp, 0 * kPointerSize));
3395 __ JumpIfNotBothSmi(index_1, index_2, &slow_case);
3396
3397 // Check that both indices are valid.
3398 // The JSArray length field is a smi since the array is in fast case mode.
3399 __ movq(temp, FieldOperand(object, JSArray::kLengthOffset));
3400 __ SmiCompare(temp, index_1);
3401 __ j(below_equal, &slow_case);
3402 __ SmiCompare(temp, index_2);
3403 __ j(below_equal, &slow_case);
3404
3405 __ SmiToInteger32(index_1, index_1);
3406 __ SmiToInteger32(index_2, index_2);
3407 // Bring addresses into index1 and index2.
3408 __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size,
3409 FixedArray::kHeaderSize));
3410 __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size,
3411 FixedArray::kHeaderSize));
3412
3413 // Swap elements. Use object and temp as scratch registers.
3414 __ movq(object, Operand(index_1, 0));
3415 __ movq(temp, Operand(index_2, 0));
3416 __ movq(Operand(index_2, 0), object);
3417 __ movq(Operand(index_1, 0), temp);
3418
3419 Label no_remembered_set;
3420 __ CheckPageFlag(elements,
3421 temp,
3422 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3423 not_zero,
3424 &no_remembered_set,
3425 Label::kNear);
3426 // Possible optimization: do a check that both values are Smis
3427 // (or them and test against Smi mask.)
3428
3429 // We are swapping two objects in an array and the incremental marker never
3430 // pauses in the middle of scanning a single object. Therefore the
3431 // incremental marker is not disturbed, so we don't need to call the
3432 // RecordWrite stub that notifies the incremental marker.
3433 __ RememberedSetHelper(elements,
3434 index_1,
3435 temp,
3436 kDontSaveFPRegs,
3437 MacroAssembler::kFallThroughAtEnd);
3438 __ RememberedSetHelper(elements,
3439 index_2,
3440 temp,
3441 kDontSaveFPRegs,
3442 MacroAssembler::kFallThroughAtEnd);
3443
3444 __ bind(&no_remembered_set);
3445
3446 // We are done. Drop elements from the stack, and return undefined.
3447 __ addq(rsp, Immediate(3 * kPointerSize));
3448 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3449 __ jmp(&done);
3450
3451 __ bind(&slow_case);
3452 __ CallRuntime(Runtime::kSwapElements, 3);
3453
3454 __ bind(&done);
3455 context()->Plug(rax);
3456 }
3457
3458
3459 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3363 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3460 ZoneList<Expression*>* args = expr->arguments(); 3364 ZoneList<Expression*>* args = expr->arguments();
3461 ASSERT_EQ(2, args->length()); 3365 ASSERT_EQ(2, args->length());
3462 3366
3463 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3367 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3464 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3368 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3465 3369
3466 Handle<FixedArray> jsfunction_result_caches( 3370 Handle<FixedArray> jsfunction_result_caches(
3467 isolate()->global_context()->jsfunction_result_caches()); 3371 isolate()->global_context()->jsfunction_result_caches());
3468 if (jsfunction_result_caches->length() <= cache_id) { 3372 if (jsfunction_result_caches->length() <= cache_id) {
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4599 *context_length = 0; 4503 *context_length = 0;
4600 return previous_; 4504 return previous_;
4601 } 4505 }
4602 4506
4603 4507
4604 #undef __ 4508 #undef __
4605 4509
4606 } } // namespace v8::internal 4510 } } // namespace v8::internal
4607 4511
4608 #endif // V8_TARGET_ARCH_X64 4512 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698