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

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

Issue 8363025: MIPS: port Support array literals with FAST_DOUBLE_ELEMENTS ElementsKind. (Closed)
Patch Set: Created 9 years, 2 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
« no previous file with comments | « src/mips/code-stubs-mips.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 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 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 context()->Plug(v0); 1469 context()->Plug(v0);
1470 } 1470 }
1471 } 1471 }
1472 1472
1473 1473
1474 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1474 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1475 Comment cmnt(masm_, "[ ArrayLiteral"); 1475 Comment cmnt(masm_, "[ ArrayLiteral");
1476 1476
1477 ZoneList<Expression*>* subexprs = expr->values(); 1477 ZoneList<Expression*>* subexprs = expr->values();
1478 int length = subexprs->length(); 1478 int length = subexprs->length();
1479
1480 Handle<FixedArray> constant_elements = expr->constant_elements();
1481 ASSERT_EQ(2, constant_elements->length());
1482 ElementsKind constant_elements_kind =
1483 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1484 Handle<FixedArrayBase> constant_elements_values(
1485 FixedArrayBase::cast(constant_elements->get(1)));
1486
1479 __ mov(a0, result_register()); 1487 __ mov(a0, result_register());
1480 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1488 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1481 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); 1489 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
1482 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1490 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1483 __ li(a1, Operand(expr->constant_elements())); 1491 __ li(a1, Operand(constant_elements));
1484 __ Push(a3, a2, a1); 1492 __ Push(a3, a2, a1);
1485 if (expr->constant_elements()->map() == 1493 if (constant_elements_values->map() ==
1486 isolate()->heap()->fixed_cow_array_map()) { 1494 isolate()->heap()->fixed_cow_array_map()) {
1487 FastCloneShallowArrayStub stub( 1495 FastCloneShallowArrayStub stub(
1488 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length); 1496 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
1489 __ CallStub(&stub); 1497 __ CallStub(&stub);
1490 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1498 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(),
1491 1, a1, a2); 1499 1, a1, a2);
1492 } else if (expr->depth() > 1) { 1500 } else if (expr->depth() > 1) {
1493 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1501 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1494 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1502 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1495 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); 1503 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1496 } else { 1504 } else {
1497 FastCloneShallowArrayStub stub( 1505 ASSERT(constant_elements_kind == FAST_ELEMENTS ||
1498 FastCloneShallowArrayStub::CLONE_ELEMENTS, length); 1506 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS ||
1507 FLAG_smi_only_arrays);
1508 FastCloneShallowArrayStub::Mode mode =
1509 constant_elements_kind == FAST_DOUBLE_ELEMENTS
1510 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
1511 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
1512 FastCloneShallowArrayStub stub(mode, length);
1499 __ CallStub(&stub); 1513 __ CallStub(&stub);
1500 } 1514 }
1501 1515
1502 bool result_saved = false; // Is the result saved to the stack? 1516 bool result_saved = false; // Is the result saved to the stack?
1503 1517
1504 // Emit code to evaluate all the non-constant subexpressions and to store 1518 // Emit code to evaluate all the non-constant subexpressions and to store
1505 // them into the newly cloned array. 1519 // them into the newly cloned array.
1506 for (int i = 0; i < length; i++) { 1520 for (int i = 0; i < length; i++) {
1507 Expression* subexpr = subexprs->at(i); 1521 Expression* subexpr = subexprs->at(i);
1508 // If the subexpression is a literal or a simple materialized literal it 1522 // If the subexpression is a literal or a simple materialized literal it
1509 // is already set in the cloned array. 1523 // is already set in the cloned array.
1510 if (subexpr->AsLiteral() != NULL || 1524 if (subexpr->AsLiteral() != NULL ||
1511 CompileTimeValue::IsCompileTimeValue(subexpr)) { 1525 CompileTimeValue::IsCompileTimeValue(subexpr)) {
1512 continue; 1526 continue;
1513 } 1527 }
1514 1528
1515 if (!result_saved) { 1529 if (!result_saved) {
1516 __ push(v0); 1530 __ push(v0);
1517 result_saved = true; 1531 result_saved = true;
1518 } 1532 }
1519 VisitForAccumulatorValue(subexpr); 1533 VisitForAccumulatorValue(subexpr);
1520 1534
1521 // Store the subexpression value in the array's elements.
1522 __ lw(t6, MemOperand(sp)); // Copy of array literal. 1535 __ lw(t6, MemOperand(sp)); // Copy of array literal.
1523 __ lw(a1, FieldMemOperand(t6, JSObject::kElementsOffset)); 1536 __ lw(a1, FieldMemOperand(t6, JSObject::kElementsOffset));
1537 __ lw(a2, FieldMemOperand(t6, JSObject::kMapOffset));
1524 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1538 int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1539
1540 Label element_done;
1541 Label double_elements;
1542 Label smi_element;
1543 Label slow_elements;
1544 Label fast_elements;
1545 __ CheckFastElements(a2, a3, &double_elements);
1546
1547 // FAST_SMI_ONLY_ELEMENTS or FAST_ELEMENTS
1548 __ JumpIfSmi(result_register(), &smi_element);
1549 __ CheckFastSmiOnlyElements(a2, a3, &fast_elements);
1550
1551 // Store into the array literal requires a elements transition. Call into
1552 // the runtime.
1553 __ bind(&slow_elements);
1554 __ push(t6); // Copy of array literal.
1555 __ li(a1, Operand(Smi::FromInt(i)));
1556 __ li(a2, Operand(Smi::FromInt(NONE))); // PropertyAttributes
1557 __ li(a3, Operand(Smi::FromInt(strict_mode_flag()))); // Strict mode.
1558 __ Push(a1, result_register(), a2, a3);
1559 __ CallRuntime(Runtime::kSetProperty, 5);
1560 __ Branch(&element_done);
1561
1562 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS.
1563 __ bind(&double_elements);
1564 __ li(a3, Operand(Smi::FromInt(i)));
1565 __ StoreNumberToDoubleElements(result_register(), a3, t6, a1, t0, t1, t5,
1566 t3, &slow_elements);
1567 __ Branch(&element_done);
1568
1569 // Array literal has ElementsKind of FAST_ELEMENTS and value is an object.
1570 __ bind(&fast_elements);
1525 __ sw(result_register(), FieldMemOperand(a1, offset)); 1571 __ sw(result_register(), FieldMemOperand(a1, offset));
1572 // Update the write barrier for the array store.
1526 1573
1527 Label no_map_change;
1528 __ JumpIfSmi(result_register(), &no_map_change);
1529 // Update the write barrier for the array store with v0 as the scratch
1530 // register.
1531 __ RecordWriteField( 1574 __ RecordWriteField(
1532 a1, offset, result_register(), a2, kRAHasBeenSaved, kDontSaveFPRegs, 1575 a1, offset, result_register(), a2, kRAHasBeenSaved, kDontSaveFPRegs,
1533 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 1576 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
1534 __ lw(a3, FieldMemOperand(a1, HeapObject::kMapOffset)); 1577 __ Branch(&element_done);
1535 __ CheckFastSmiOnlyElements(a3, a2, &no_map_change); 1578
1536 __ push(t6); // Copy of array literal. 1579 // Array literal has ElementsKind of FAST_SMI_ONLY_ELEMENTS or
1537 __ CallRuntime(Runtime::kNonSmiElementStored, 1); 1580 // FAST_ELEMENTS, and value is Smi.
1538 __ bind(&no_map_change); 1581 __ bind(&smi_element);
1582 __ sw(result_register(), FieldMemOperand(a1, offset));
1583 // Fall through
1584
1585 __ bind(&element_done);
1539 1586
1540 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1587 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS);
1541 } 1588 }
1542 1589
1543 if (result_saved) { 1590 if (result_saved) {
1544 context()->PlugTOS(); 1591 context()->PlugTOS();
1545 } else { 1592 } else {
1546 context()->Plug(v0); 1593 context()->Plug(v0);
1547 } 1594 }
1548 } 1595 }
(...skipping 2738 matching lines...) Expand 10 before | Expand all | Expand 10 after
4287 *context_length = 0; 4334 *context_length = 0;
4288 return previous_; 4335 return previous_;
4289 } 4336 }
4290 4337
4291 4338
4292 #undef __ 4339 #undef __
4293 4340
4294 } } // namespace v8::internal 4341 } } // namespace v8::internal
4295 4342
4296 #endif // V8_TARGET_ARCH_MIPS 4343 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698