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 8883049: Merge patches to 3.7 to make MIPS work. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.7/
Patch Set: Created 9 years 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/mips/codegen-mips.cc ('k') | src/mips/lithium-codegen-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 // v0: Newly allocated regexp. 1417 // v0: Newly allocated regexp.
1418 // t1: Materialized regexp. 1418 // t1: Materialized regexp.
1419 // a2: temp. 1419 // a2: temp.
1420 __ CopyFields(v0, t1, a2.bit(), size / kPointerSize); 1420 __ CopyFields(v0, t1, a2.bit(), size / kPointerSize);
1421 context()->Plug(v0); 1421 context()->Plug(v0);
1422 } 1422 }
1423 1423
1424 1424
1425 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1425 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1426 Comment cmnt(masm_, "[ ObjectLiteral"); 1426 Comment cmnt(masm_, "[ ObjectLiteral");
1427 Handle<FixedArray> constant_properties = expr->constant_properties();
1427 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1428 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1428 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); 1429 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
1429 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1430 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1430 __ li(a1, Operand(expr->constant_properties())); 1431 __ li(a1, Operand(constant_properties));
1431 int flags = expr->fast_elements() 1432 int flags = expr->fast_elements()
1432 ? ObjectLiteral::kFastElements 1433 ? ObjectLiteral::kFastElements
1433 : ObjectLiteral::kNoFlags; 1434 : ObjectLiteral::kNoFlags;
1434 flags |= expr->has_function() 1435 flags |= expr->has_function()
1435 ? ObjectLiteral::kHasFunction 1436 ? ObjectLiteral::kHasFunction
1436 : ObjectLiteral::kNoFlags; 1437 : ObjectLiteral::kNoFlags;
1437 __ li(a0, Operand(Smi::FromInt(flags))); 1438 __ li(a0, Operand(Smi::FromInt(flags)));
1438 __ Push(a3, a2, a1, a0); 1439 __ Push(a3, a2, a1, a0);
1440 int properties_count = constant_properties->length() / 2;
1439 if (expr->depth() > 1) { 1441 if (expr->depth() > 1) {
1440 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1442 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1443 } else if (flags != ObjectLiteral::kFastElements ||
1444 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1445 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
1441 } else { 1446 } else {
1442 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); 1447 FastCloneShallowObjectStub stub(properties_count);
1448 __ CallStub(&stub);
1443 } 1449 }
1444 1450
1445 // If result_saved is true the result is on top of the stack. If 1451 // If result_saved is true the result is on top of the stack. If
1446 // result_saved is false the result is in v0. 1452 // result_saved is false the result is in v0.
1447 bool result_saved = false; 1453 bool result_saved = false;
1448 1454
1449 // Mark all computed expressions that are bound to a key that 1455 // Mark all computed expressions that are bound to a key that
1450 // is shadowed by a later occurrence of the same key. For the 1456 // is shadowed by a later occurrence of the same key. For the
1451 // marked expressions, no store code is emitted. 1457 // marked expressions, no store code is emitted.
1452 expr->CalculateEmitStore(); 1458 expr->CalculateEmitStore();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1539 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1534 Comment cmnt(masm_, "[ ArrayLiteral"); 1540 Comment cmnt(masm_, "[ ArrayLiteral");
1535 1541
1536 ZoneList<Expression*>* subexprs = expr->values(); 1542 ZoneList<Expression*>* subexprs = expr->values();
1537 int length = subexprs->length(); 1543 int length = subexprs->length();
1538 1544
1539 Handle<FixedArray> constant_elements = expr->constant_elements(); 1545 Handle<FixedArray> constant_elements = expr->constant_elements();
1540 ASSERT_EQ(2, constant_elements->length()); 1546 ASSERT_EQ(2, constant_elements->length());
1541 ElementsKind constant_elements_kind = 1547 ElementsKind constant_elements_kind =
1542 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1548 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1549 bool has_fast_elements = constant_elements_kind == FAST_ELEMENTS;
1543 Handle<FixedArrayBase> constant_elements_values( 1550 Handle<FixedArrayBase> constant_elements_values(
1544 FixedArrayBase::cast(constant_elements->get(1))); 1551 FixedArrayBase::cast(constant_elements->get(1)));
1545 1552
1546 __ mov(a0, result_register()); 1553 __ mov(a0, result_register());
1547 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1554 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1548 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); 1555 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
1549 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1556 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1550 __ li(a1, Operand(constant_elements)); 1557 __ li(a1, Operand(constant_elements));
1551 __ Push(a3, a2, a1); 1558 __ Push(a3, a2, a1);
1552 if (constant_elements_values->map() == 1559 if (has_fast_elements && constant_elements_values->map() ==
1553 isolate()->heap()->fixed_cow_array_map()) { 1560 isolate()->heap()->fixed_cow_array_map()) {
1554 FastCloneShallowArrayStub stub( 1561 FastCloneShallowArrayStub stub(
1555 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length); 1562 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
1556 __ CallStub(&stub); 1563 __ CallStub(&stub);
1557 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1564 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(),
1558 1, a1, a2); 1565 1, a1, a2);
1559 } else if (expr->depth() > 1) { 1566 } else if (expr->depth() > 1) {
1560 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1567 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1561 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1568 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1562 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); 1569 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1563 } else { 1570 } else {
1564 ASSERT(constant_elements_kind == FAST_ELEMENTS || 1571 ASSERT(constant_elements_kind == FAST_ELEMENTS ||
1565 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS || 1572 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS ||
1566 FLAG_smi_only_arrays); 1573 FLAG_smi_only_arrays);
1567 FastCloneShallowArrayStub::Mode mode = 1574 FastCloneShallowArrayStub::Mode mode = has_fast_elements
1568 constant_elements_kind == FAST_DOUBLE_ELEMENTS 1575 ? FastCloneShallowArrayStub::CLONE_ELEMENTS
1569 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 1576 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1570 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
1571 FastCloneShallowArrayStub stub(mode, length); 1577 FastCloneShallowArrayStub stub(mode, length);
1572 __ CallStub(&stub); 1578 __ CallStub(&stub);
1573 } 1579 }
1574 1580
1575 bool result_saved = false; // Is the result saved to the stack? 1581 bool result_saved = false; // Is the result saved to the stack?
1576 1582
1577 // Emit code to evaluate all the non-constant subexpressions and to store 1583 // Emit code to evaluate all the non-constant subexpressions and to store
1578 // them into the newly cloned array. 1584 // them into the newly cloned array.
1579 for (int i = 0; i < length; i++) { 1585 for (int i = 0; i < length; i++) {
1580 Expression* subexpr = subexprs->at(i); 1586 Expression* subexpr = subexprs->at(i);
1581 // If the subexpression is a literal or a simple materialized literal it 1587 // If the subexpression is a literal or a simple materialized literal it
1582 // is already set in the cloned array. 1588 // is already set in the cloned array.
1583 if (subexpr->AsLiteral() != NULL || 1589 if (subexpr->AsLiteral() != NULL ||
1584 CompileTimeValue::IsCompileTimeValue(subexpr)) { 1590 CompileTimeValue::IsCompileTimeValue(subexpr)) {
1585 continue; 1591 continue;
1586 } 1592 }
1587 1593
1588 if (!result_saved) { 1594 if (!result_saved) {
1589 __ push(v0); 1595 __ push(v0);
1590 result_saved = true; 1596 result_saved = true;
1591 } 1597 }
1598
1592 VisitForAccumulatorValue(subexpr); 1599 VisitForAccumulatorValue(subexpr);
1593 1600
1594 __ lw(t6, MemOperand(sp)); // Copy of array literal. 1601 if (constant_elements_kind == FAST_ELEMENTS) {
1595 __ lw(a1, FieldMemOperand(t6, JSObject::kElementsOffset)); 1602 int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1596 __ lw(a2, FieldMemOperand(t6, JSObject::kMapOffset)); 1603 __ lw(t2, MemOperand(sp)); // Copy of array literal.
1597 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1604 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset));
1598 1605 __ sw(result_register(), FieldMemOperand(a1, offset));
1599 Label element_done; 1606 // Update the write barrier for the array store.
1600 Label double_elements; 1607 __ RecordWriteField(a1, offset, result_register(), a2,
1601 Label smi_element; 1608 kRAHasBeenSaved, kDontSaveFPRegs,
1602 Label slow_elements; 1609 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1603 Label fast_elements; 1610 } else {
1604 __ CheckFastElements(a2, a3, &double_elements); 1611 __ lw(a1, MemOperand(sp)); // Copy of array literal.
1605 1612 __ lw(a2, FieldMemOperand(a1, JSObject::kMapOffset));
1606 // FAST_SMI_ONLY_ELEMENTS or FAST_ELEMENTS 1613 __ li(a3, Operand(Smi::FromInt(i)));
1607 __ JumpIfSmi(result_register(), &smi_element); 1614 __ li(t0, Operand(Smi::FromInt(expr->literal_index())));
1608 __ CheckFastSmiOnlyElements(a2, a3, &fast_elements); 1615 __ mov(a0, result_register());
1609 1616 StoreArrayLiteralElementStub stub;
1610 // Store into the array literal requires a elements transition. Call into 1617 __ CallStub(&stub);
1611 // the runtime. 1618 }
1612 __ bind(&slow_elements);
1613 __ push(t6); // Copy of array literal.
1614 __ li(a1, Operand(Smi::FromInt(i)));
1615 __ li(a2, Operand(Smi::FromInt(NONE))); // PropertyAttributes
1616 StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE)
1617 ? kNonStrictMode : kStrictMode;
1618 __ li(a3, Operand(Smi::FromInt(strict_mode_flag))); // Strict mode.
1619 __ Push(a1, result_register(), a2, a3);
1620 __ CallRuntime(Runtime::kSetProperty, 5);
1621 __ Branch(&element_done);
1622
1623 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS.
1624 __ bind(&double_elements);
1625 __ li(a3, Operand(Smi::FromInt(i)));
1626 __ StoreNumberToDoubleElements(result_register(), a3, t6, a1, t0, t1, t5,
1627 t3, &slow_elements);
1628 __ Branch(&element_done);
1629
1630 // Array literal has ElementsKind of FAST_ELEMENTS and value is an object.
1631 __ bind(&fast_elements);
1632 __ sw(result_register(), FieldMemOperand(a1, offset));
1633 // Update the write barrier for the array store.
1634
1635 __ RecordWriteField(
1636 a1, offset, result_register(), a2, kRAHasBeenSaved, kDontSaveFPRegs,
1637 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
1638 __ Branch(&element_done);
1639
1640 // Array literal has ElementsKind of FAST_SMI_ONLY_ELEMENTS or
1641 // FAST_ELEMENTS, and value is Smi.
1642 __ bind(&smi_element);
1643 __ sw(result_register(), FieldMemOperand(a1, offset));
1644 // Fall through
1645
1646 __ bind(&element_done);
1647 1619
1648 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1620 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS);
1649 } 1621 }
1650
1651 if (result_saved) { 1622 if (result_saved) {
1652 context()->PlugTOS(); 1623 context()->PlugTOS();
1653 } else { 1624 } else {
1654 context()->Plug(v0); 1625 context()->Plug(v0);
1655 } 1626 }
1656 } 1627 }
1657 1628
1658 1629
1659 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1630 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1660 Comment cmnt(masm_, "[ Assignment"); 1631 Comment cmnt(masm_, "[ Assignment");
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 *context_length = 0; 4422 *context_length = 0;
4452 return previous_; 4423 return previous_;
4453 } 4424 }
4454 4425
4455 4426
4456 #undef __ 4427 #undef __
4457 4428
4458 } } // namespace v8::internal 4429 } } // namespace v8::internal
4459 4430
4460 #endif // V8_TARGET_ARCH_MIPS 4431 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/codegen-mips.cc ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698