| OLD | NEW |
| 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 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3398 ZoneList<Expression*>* args = expr->arguments(); | 3398 ZoneList<Expression*>* args = expr->arguments(); |
| 3399 ASSERT(args->length() == 3); | 3399 ASSERT(args->length() == 3); |
| 3400 VisitForStackValue(args->at(0)); | 3400 VisitForStackValue(args->at(0)); |
| 3401 VisitForStackValue(args->at(1)); | 3401 VisitForStackValue(args->at(1)); |
| 3402 VisitForStackValue(args->at(2)); | 3402 VisitForStackValue(args->at(2)); |
| 3403 __ CallStub(&stub); | 3403 __ CallStub(&stub); |
| 3404 context()->Plug(eax); | 3404 context()->Plug(eax); |
| 3405 } | 3405 } |
| 3406 | 3406 |
| 3407 | 3407 |
| 3408 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) { | |
| 3409 ZoneList<Expression*>* args = expr->arguments(); | |
| 3410 ASSERT(args->length() == 3); | |
| 3411 VisitForStackValue(args->at(0)); | |
| 3412 VisitForStackValue(args->at(1)); | |
| 3413 VisitForStackValue(args->at(2)); | |
| 3414 Label done; | |
| 3415 Label slow_case; | |
| 3416 Register object = eax; | |
| 3417 Register index_1 = ebx; | |
| 3418 Register index_2 = ecx; | |
| 3419 Register elements = edi; | |
| 3420 Register temp = edx; | |
| 3421 __ mov(object, Operand(esp, 2 * kPointerSize)); | |
| 3422 // Fetch the map and check if array is in fast case. | |
| 3423 // Check that object doesn't require security checks and | |
| 3424 // has no indexed interceptor. | |
| 3425 __ CmpObjectType(object, JS_ARRAY_TYPE, temp); | |
| 3426 __ j(not_equal, &slow_case); | |
| 3427 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), | |
| 3428 KeyedLoadIC::kSlowCaseBitFieldMask); | |
| 3429 __ j(not_zero, &slow_case); | |
| 3430 | |
| 3431 // Check the object's elements are in fast case and writable. | |
| 3432 __ mov(elements, FieldOperand(object, JSObject::kElementsOffset)); | |
| 3433 __ cmp(FieldOperand(elements, HeapObject::kMapOffset), | |
| 3434 Immediate(isolate()->factory()->fixed_array_map())); | |
| 3435 __ j(not_equal, &slow_case); | |
| 3436 | |
| 3437 // Check that both indices are smis. | |
| 3438 __ mov(index_1, Operand(esp, 1 * kPointerSize)); | |
| 3439 __ mov(index_2, Operand(esp, 0)); | |
| 3440 __ mov(temp, index_1); | |
| 3441 __ or_(temp, index_2); | |
| 3442 __ JumpIfNotSmi(temp, &slow_case); | |
| 3443 | |
| 3444 // Check that both indices are valid. | |
| 3445 __ mov(temp, FieldOperand(object, JSArray::kLengthOffset)); | |
| 3446 __ cmp(temp, index_1); | |
| 3447 __ j(below_equal, &slow_case); | |
| 3448 __ cmp(temp, index_2); | |
| 3449 __ j(below_equal, &slow_case); | |
| 3450 | |
| 3451 // Bring addresses into index1 and index2. | |
| 3452 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); | |
| 3453 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); | |
| 3454 | |
| 3455 // Swap elements. Use object and temp as scratch registers. | |
| 3456 __ mov(object, Operand(index_1, 0)); | |
| 3457 __ mov(temp, Operand(index_2, 0)); | |
| 3458 __ mov(Operand(index_2, 0), object); | |
| 3459 __ mov(Operand(index_1, 0), temp); | |
| 3460 | |
| 3461 Label no_remembered_set; | |
| 3462 __ CheckPageFlag(elements, | |
| 3463 temp, | |
| 3464 1 << MemoryChunk::SCAN_ON_SCAVENGE, | |
| 3465 not_zero, | |
| 3466 &no_remembered_set, | |
| 3467 Label::kNear); | |
| 3468 // Possible optimization: do a check that both values are Smis | |
| 3469 // (or them and test against Smi mask.) | |
| 3470 | |
| 3471 // We are swapping two objects in an array and the incremental marker never | |
| 3472 // pauses in the middle of scanning a single object. Therefore the | |
| 3473 // incremental marker is not disturbed, so we don't need to call the | |
| 3474 // RecordWrite stub that notifies the incremental marker. | |
| 3475 __ RememberedSetHelper(elements, | |
| 3476 index_1, | |
| 3477 temp, | |
| 3478 kDontSaveFPRegs, | |
| 3479 MacroAssembler::kFallThroughAtEnd); | |
| 3480 __ RememberedSetHelper(elements, | |
| 3481 index_2, | |
| 3482 temp, | |
| 3483 kDontSaveFPRegs, | |
| 3484 MacroAssembler::kFallThroughAtEnd); | |
| 3485 | |
| 3486 __ bind(&no_remembered_set); | |
| 3487 | |
| 3488 // We are done. Drop elements from the stack, and return undefined. | |
| 3489 __ add(esp, Immediate(3 * kPointerSize)); | |
| 3490 __ mov(eax, isolate()->factory()->undefined_value()); | |
| 3491 __ jmp(&done); | |
| 3492 | |
| 3493 __ bind(&slow_case); | |
| 3494 __ CallRuntime(Runtime::kSwapElements, 3); | |
| 3495 | |
| 3496 __ bind(&done); | |
| 3497 context()->Plug(eax); | |
| 3498 } | |
| 3499 | |
| 3500 | |
| 3501 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3408 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3502 ZoneList<Expression*>* args = expr->arguments(); | 3409 ZoneList<Expression*>* args = expr->arguments(); |
| 3503 ASSERT_EQ(2, args->length()); | 3410 ASSERT_EQ(2, args->length()); |
| 3504 | 3411 |
| 3505 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3412 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 3506 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3413 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
| 3507 | 3414 |
| 3508 Handle<FixedArray> jsfunction_result_caches( | 3415 Handle<FixedArray> jsfunction_result_caches( |
| 3509 isolate()->global_context()->jsfunction_result_caches()); | 3416 isolate()->global_context()->jsfunction_result_caches()); |
| 3510 if (jsfunction_result_caches->length() <= cache_id) { | 3417 if (jsfunction_result_caches->length() <= cache_id) { |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4611 *context_length = 0; | 4518 *context_length = 0; |
| 4612 return previous_; | 4519 return previous_; |
| 4613 } | 4520 } |
| 4614 | 4521 |
| 4615 | 4522 |
| 4616 #undef __ | 4523 #undef __ |
| 4617 | 4524 |
| 4618 } } // namespace v8::internal | 4525 } } // namespace v8::internal |
| 4619 | 4526 |
| 4620 #endif // V8_TARGET_ARCH_IA32 | 4527 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |