Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 for (int i = 0; i < num_parameters; i++) { | 110 for (int i = 0; i < num_parameters; i++) { |
| 111 Slot* slot = scope()->parameter(i)->AsSlot(); | 111 Slot* slot = scope()->parameter(i)->AsSlot(); |
| 112 if (slot != NULL && slot->type() == Slot::CONTEXT) { | 112 if (slot != NULL && slot->type() == Slot::CONTEXT) { |
| 113 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 113 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 114 (num_parameters - 1 - i) * kPointerSize; | 114 (num_parameters - 1 - i) * kPointerSize; |
| 115 // Load parameter from stack. | 115 // Load parameter from stack. |
| 116 __ ldr(r0, MemOperand(fp, parameter_offset)); | 116 __ ldr(r0, MemOperand(fp, parameter_offset)); |
| 117 // Store it in the context. | 117 // Store it in the context. |
| 118 __ mov(r1, Operand(Context::SlotOffset(slot->index()))); | 118 __ mov(r1, Operand(Context::SlotOffset(slot->index()))); |
| 119 __ str(r0, MemOperand(cp, r1)); | 119 __ str(r0, MemOperand(cp, r1)); |
| 120 | |
| 121 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 120 // Update the write barrier. This clobbers all involved | 122 // Update the write barrier. This clobbers all involved |
| 121 // registers, so we have to use two more registers to avoid | 123 // registers, so we have to use two more registers to avoid |
| 122 // clobbering cp. | 124 // clobbering cp. |
| 123 __ mov(r2, Operand(cp)); | 125 __ mov(r2, Operand(cp)); |
| 124 __ RecordWrite(r2, Operand(r1), r3, r0); | 126 __ RecordWrite(r2, Operand(r1), r3, r0); |
| 127 #endif | |
| 125 } | 128 } |
| 126 } | 129 } |
| 127 } | 130 } |
| 128 | 131 |
| 129 Variable* arguments = scope()->arguments(); | 132 Variable* arguments = scope()->arguments(); |
| 130 if (arguments != NULL) { | 133 if (arguments != NULL) { |
| 131 // Function uses arguments object. | 134 // Function uses arguments object. |
| 132 Comment cmnt(masm_, "[ Allocate arguments object"); | 135 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 133 if (!function_in_register) { | 136 if (!function_in_register) { |
| 134 // Load this again, if it's used by the local context below. | 137 // Load this again, if it's used by the local context below. |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 | 548 |
| 546 | 549 |
| 547 void FullCodeGenerator::Move(Slot* dst, | 550 void FullCodeGenerator::Move(Slot* dst, |
| 548 Register src, | 551 Register src, |
| 549 Register scratch1, | 552 Register scratch1, |
| 550 Register scratch2) { | 553 Register scratch2) { |
| 551 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. | 554 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. |
| 552 ASSERT(!scratch1.is(src) && !scratch2.is(src)); | 555 ASSERT(!scratch1.is(src) && !scratch2.is(src)); |
| 553 MemOperand location = EmitSlotSearch(dst, scratch1); | 556 MemOperand location = EmitSlotSearch(dst, scratch1); |
| 554 __ str(src, location); | 557 __ str(src, location); |
| 558 | |
| 559 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 555 // Emit the write barrier code if the location is in the heap. | 560 // Emit the write barrier code if the location is in the heap. |
| 556 if (dst->type() == Slot::CONTEXT) { | 561 if (dst->type() == Slot::CONTEXT) { |
| 557 __ RecordWrite(scratch1, | 562 __ RecordWrite(scratch1, |
| 558 Operand(Context::SlotOffset(dst->index())), | 563 Operand(Context::SlotOffset(dst->index())), |
| 559 scratch2, | 564 scratch2, |
| 560 src); | 565 src); |
| 561 } | 566 } |
| 567 #endif | |
| 562 } | 568 } |
| 563 | 569 |
| 564 | 570 |
| 565 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, | 571 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, |
| 566 bool should_normalize, | 572 bool should_normalize, |
| 567 Label* if_true, | 573 Label* if_true, |
| 568 Label* if_false) { | 574 Label* if_false) { |
| 569 // Only prepare for bailouts before splits if we're in a test | 575 // Only prepare for bailouts before splits if we're in a test |
| 570 // context. Otherwise, we let the Visit function deal with the | 576 // context. Otherwise, we let the Visit function deal with the |
| 571 // preparation to avoid preparing with the same AST id twice. | 577 // preparation to avoid preparing with the same AST id twice. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 __ cmp(r1, cp); | 628 __ cmp(r1, cp); |
| 623 __ Check(eq, "Unexpected declaration in current context."); | 629 __ Check(eq, "Unexpected declaration in current context."); |
| 624 } | 630 } |
| 625 if (mode == Variable::CONST) { | 631 if (mode == Variable::CONST) { |
| 626 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 632 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 627 __ str(ip, ContextOperand(cp, slot->index())); | 633 __ str(ip, ContextOperand(cp, slot->index())); |
| 628 // No write barrier since the_hole_value is in old space. | 634 // No write barrier since the_hole_value is in old space. |
| 629 } else if (function != NULL) { | 635 } else if (function != NULL) { |
| 630 VisitForAccumulatorValue(function); | 636 VisitForAccumulatorValue(function); |
| 631 __ str(result_register(), ContextOperand(cp, slot->index())); | 637 __ str(result_register(), ContextOperand(cp, slot->index())); |
| 638 | |
| 639 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 632 int offset = Context::SlotOffset(slot->index()); | 640 int offset = Context::SlotOffset(slot->index()); |
|
Erik Corry
2010/12/14 21:05:26
Seems like this ifdef and about 10 others could ha
| |
| 633 // We know that we have written a function, which is not a smi. | 641 // We know that we have written a function, which is not a smi. |
| 634 __ mov(r1, Operand(cp)); | 642 __ mov(r1, Operand(cp)); |
| 635 __ RecordWrite(r1, Operand(offset), r2, result_register()); | 643 __ RecordWrite(r1, Operand(offset), r2, result_register()); |
| 644 #endif | |
| 636 } | 645 } |
| 637 break; | 646 break; |
| 638 | 647 |
| 639 case Slot::LOOKUP: { | 648 case Slot::LOOKUP: { |
| 640 __ mov(r2, Operand(variable->name())); | 649 __ mov(r2, Operand(variable->name())); |
| 641 // Declaration nodes are always introduced in one of two modes. | 650 // Declaration nodes are always introduced in one of two modes. |
| 642 ASSERT(mode == Variable::VAR || | 651 ASSERT(mode == Variable::VAR || |
| 643 mode == Variable::CONST); | 652 mode == Variable::CONST); |
| 644 PropertyAttributes attr = | 653 PropertyAttributes attr = |
| 645 (mode == Variable::VAR) ? NONE : READ_ONLY; | 654 (mode == Variable::VAR) ? NONE : READ_ONLY; |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1345 result_saved = true; | 1354 result_saved = true; |
| 1346 } | 1355 } |
| 1347 VisitForAccumulatorValue(subexpr); | 1356 VisitForAccumulatorValue(subexpr); |
| 1348 | 1357 |
| 1349 // Store the subexpression value in the array's elements. | 1358 // Store the subexpression value in the array's elements. |
| 1350 __ ldr(r1, MemOperand(sp)); // Copy of array literal. | 1359 __ ldr(r1, MemOperand(sp)); // Copy of array literal. |
| 1351 __ ldr(r1, FieldMemOperand(r1, JSObject::kElementsOffset)); | 1360 __ ldr(r1, FieldMemOperand(r1, JSObject::kElementsOffset)); |
| 1352 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1361 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1353 __ str(result_register(), FieldMemOperand(r1, offset)); | 1362 __ str(result_register(), FieldMemOperand(r1, offset)); |
| 1354 | 1363 |
| 1364 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 1355 // Update the write barrier for the array store with r0 as the scratch | 1365 // Update the write barrier for the array store with r0 as the scratch |
| 1356 // register. | 1366 // register. |
| 1357 __ RecordWrite(r1, Operand(offset), r2, result_register()); | 1367 __ RecordWrite(r1, Operand(offset), r2, result_register()); |
| 1368 #endif | |
| 1358 | 1369 |
| 1359 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1370 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
| 1360 } | 1371 } |
| 1361 | 1372 |
| 1362 if (result_saved) { | 1373 if (result_saved) { |
| 1363 context()->PlugTOS(); | 1374 context()->PlugTOS(); |
| 1364 } else { | 1375 } else { |
| 1365 context()->Plug(r0); | 1376 context()->Plug(r0); |
| 1366 } | 1377 } |
| 1367 } | 1378 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1633 MemOperand target = EmitSlotSearch(slot, r1); | 1644 MemOperand target = EmitSlotSearch(slot, r1); |
| 1634 if (op == Token::INIT_CONST) { | 1645 if (op == Token::INIT_CONST) { |
| 1635 // Detect const reinitialization by checking for the hole value. | 1646 // Detect const reinitialization by checking for the hole value. |
| 1636 __ ldr(r2, target); | 1647 __ ldr(r2, target); |
| 1637 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 1648 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 1638 __ cmp(r2, ip); | 1649 __ cmp(r2, ip); |
| 1639 __ b(ne, &done); | 1650 __ b(ne, &done); |
| 1640 } | 1651 } |
| 1641 // Perform the assignment and issue the write barrier. | 1652 // Perform the assignment and issue the write barrier. |
| 1642 __ str(result_register(), target); | 1653 __ str(result_register(), target); |
| 1654 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 1643 // RecordWrite may destroy all its register arguments. | 1655 // RecordWrite may destroy all its register arguments. |
| 1644 __ mov(r3, result_register()); | 1656 __ mov(r3, result_register()); |
| 1645 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; | 1657 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; |
| 1646 __ RecordWrite(r1, Operand(offset), r2, r3); | 1658 __ RecordWrite(r1, Operand(offset), r2, r3); |
| 1659 #endif | |
| 1647 break; | 1660 break; |
| 1648 } | 1661 } |
| 1649 | 1662 |
| 1650 case Slot::LOOKUP: | 1663 case Slot::LOOKUP: |
| 1651 // Call the runtime for the assignment. The runtime will ignore | 1664 // Call the runtime for the assignment. The runtime will ignore |
| 1652 // const reinitialization. | 1665 // const reinitialization. |
| 1653 __ push(r0); // Value. | 1666 __ push(r0); // Value. |
| 1654 __ mov(r0, Operand(slot->var()->name())); | 1667 __ mov(r0, Operand(slot->var()->name())); |
| 1655 __ Push(cp, r0); // Context and name. | 1668 __ Push(cp, r0); // Context and name. |
| 1656 if (op == Token::INIT_CONST) { | 1669 if (op == Token::INIT_CONST) { |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2538 Label done; | 2551 Label done; |
| 2539 // If the object is a smi, return the value. | 2552 // If the object is a smi, return the value. |
| 2540 __ BranchOnSmi(r1, &done); | 2553 __ BranchOnSmi(r1, &done); |
| 2541 | 2554 |
| 2542 // If the object is not a value type, return the value. | 2555 // If the object is not a value type, return the value. |
| 2543 __ CompareObjectType(r1, r2, r2, JS_VALUE_TYPE); | 2556 __ CompareObjectType(r1, r2, r2, JS_VALUE_TYPE); |
| 2544 __ b(ne, &done); | 2557 __ b(ne, &done); |
| 2545 | 2558 |
| 2546 // Store the value. | 2559 // Store the value. |
| 2547 __ str(r0, FieldMemOperand(r1, JSValue::kValueOffset)); | 2560 __ str(r0, FieldMemOperand(r1, JSValue::kValueOffset)); |
| 2561 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 2548 // Update the write barrier. Save the value as it will be | 2562 // Update the write barrier. Save the value as it will be |
| 2549 // overwritten by the write barrier code and is needed afterward. | 2563 // overwritten by the write barrier code and is needed afterward. |
| 2550 __ RecordWrite(r1, Operand(JSValue::kValueOffset - kHeapObjectTag), r2, r3); | 2564 __ RecordWrite(r1, Operand(JSValue::kValueOffset - kHeapObjectTag), r2, r3); |
| 2565 #endif | |
| 2551 | 2566 |
| 2552 __ bind(&done); | 2567 __ bind(&done); |
| 2553 context()->Plug(r0); | 2568 context()->Plug(r0); |
| 2554 } | 2569 } |
| 2555 | 2570 |
| 2556 | 2571 |
| 2557 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { | 2572 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { |
| 2558 ASSERT_EQ(args->length(), 1); | 2573 ASSERT_EQ(args->length(), 1); |
| 2559 | 2574 |
| 2560 // Load the argument on the stack and call the stub. | 2575 // Load the argument on the stack and call the stub. |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3591 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 3606 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 3592 __ add(pc, r1, Operand(masm_->CodeObject())); | 3607 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 3593 } | 3608 } |
| 3594 | 3609 |
| 3595 | 3610 |
| 3596 #undef __ | 3611 #undef __ |
| 3597 | 3612 |
| 3598 } } // namespace v8::internal | 3613 } } // namespace v8::internal |
| 3599 | 3614 |
| 3600 #endif // V8_TARGET_ARCH_ARM | 3615 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |