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

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

Issue 8590026: Optimize array literal boilerplate copy for fast cases. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove unneeded difs Created 9 years, 1 month 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/x64/code-stubs-x64.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 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 } 1473 }
1474 1474
1475 1475
1476 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1476 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1477 Comment cmnt(masm_, "[ ArrayLiteral"); 1477 Comment cmnt(masm_, "[ ArrayLiteral");
1478 1478
1479 ZoneList<Expression*>* subexprs = expr->values(); 1479 ZoneList<Expression*>* subexprs = expr->values();
1480 int length = subexprs->length(); 1480 int length = subexprs->length();
1481 Handle<FixedArray> constant_elements = expr->constant_elements(); 1481 Handle<FixedArray> constant_elements = expr->constant_elements();
1482 ASSERT_EQ(2, constant_elements->length()); 1482 ASSERT_EQ(2, constant_elements->length());
1483 #if DEBUG
1484 ElementsKind constant_elements_kind = 1483 ElementsKind constant_elements_kind =
1485 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1484 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1486 #endif 1485 bool has_constant_fast_elements = constant_elements_kind == FAST_ELEMENTS;
1487 Handle<FixedArrayBase> constant_elements_values( 1486 Handle<FixedArrayBase> constant_elements_values(
1488 FixedArrayBase::cast(constant_elements->get(1))); 1487 FixedArrayBase::cast(constant_elements->get(1)));
1489 1488
1490 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1489 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1491 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1490 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1492 __ Push(Smi::FromInt(expr->literal_index())); 1491 __ Push(Smi::FromInt(expr->literal_index()));
1493 __ Push(constant_elements); 1492 __ Push(constant_elements);
1494 if (expr->depth() > 1) { 1493 Heap* heap = isolate()->heap();
1494 if (has_constant_fast_elements &&
1495 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1496 // If the elements are already FAST_ELEMENTS, the boilerplate cannot
1497 // change, so it's possible to specialize the stub in advance.
1498 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1499 FastCloneShallowArrayStub stub(
1500 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1501 length);
1502 __ CallStub(&stub);
1503 } else if (expr->depth() > 1) {
1495 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1504 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1496 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1505 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1497 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); 1506 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1498 } else { 1507 } else {
1499 ASSERT(constant_elements_kind == FAST_ELEMENTS || 1508 ASSERT(constant_elements_kind == FAST_ELEMENTS ||
1500 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS || 1509 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS ||
1501 FLAG_smi_only_arrays); 1510 FLAG_smi_only_arrays);
1502 if (constant_elements_values->map() == 1511 // If the elements are already FAST_ELEMENTS, the boilerplate cannot
1503 isolate()->heap()->fixed_cow_array_map()) { 1512 // change, so it's possible to specialize the stub in advance.
1504 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1513 FastCloneShallowArrayStub::Mode mode = has_constant_fast_elements
1505 1); 1514 ? FastCloneShallowArrayStub::CLONE_ELEMENTS
1506 } 1515 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1507 FastCloneShallowArrayStub stub( 1516 FastCloneShallowArrayStub stub(mode, length);
1508 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS, length);
1509 __ CallStub(&stub); 1517 __ CallStub(&stub);
1510 } 1518 }
1511 1519
1512 bool result_saved = false; // Is the result saved to the stack? 1520 bool result_saved = false; // Is the result saved to the stack?
1513 1521
1514 // Emit code to evaluate all the non-constant subexpressions and to store 1522 // Emit code to evaluate all the non-constant subexpressions and to store
1515 // them into the newly cloned array. 1523 // them into the newly cloned array.
1516 for (int i = 0; i < length; i++) { 1524 for (int i = 0; i < length; i++) {
1517 Expression* subexpr = subexprs->at(i); 1525 Expression* subexpr = subexprs->at(i);
1518 // If the subexpression is a literal or a simple materialized literal it 1526 // If the subexpression is a literal or a simple materialized literal it
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after
4305 *context_length = 0; 4313 *context_length = 0;
4306 return previous_; 4314 return previous_;
4307 } 4315 }
4308 4316
4309 4317
4310 #undef __ 4318 #undef __
4311 4319
4312 } } // namespace v8::internal 4320 } } // namespace v8::internal
4313 4321
4314 #endif // V8_TARGET_ARCH_X64 4322 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698