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

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

Issue 8574053: Add ia32 FastCloneShallowArrayStub that copies all boilerplate kinds. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback 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/ia32/code-stubs-ia32.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 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1470 }
1471 1471
1472 1472
1473 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1473 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1474 Comment cmnt(masm_, "[ ArrayLiteral"); 1474 Comment cmnt(masm_, "[ ArrayLiteral");
1475 1475
1476 ZoneList<Expression*>* subexprs = expr->values(); 1476 ZoneList<Expression*>* subexprs = expr->values();
1477 int length = subexprs->length(); 1477 int length = subexprs->length();
1478 Handle<FixedArray> constant_elements = expr->constant_elements(); 1478 Handle<FixedArray> constant_elements = expr->constant_elements();
1479 ASSERT_EQ(2, constant_elements->length()); 1479 ASSERT_EQ(2, constant_elements->length());
1480 ElementsKind constant_elements_kind =
1481 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1482 Handle<FixedArrayBase> constant_elements_values( 1480 Handle<FixedArrayBase> constant_elements_values(
1483 FixedArrayBase::cast(constant_elements->get(1))); 1481 FixedArrayBase::cast(constant_elements->get(1)));
1484 1482
1485 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1483 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1486 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); 1484 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
1487 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 1485 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1488 __ push(Immediate(constant_elements)); 1486 __ push(Immediate(constant_elements));
1489 if (constant_elements_values->map() == 1487 if (expr->depth() > 1) {
1490 isolate()->heap()->fixed_cow_array_map()) {
1491 ASSERT(expr->depth() == 1);
1492 FastCloneShallowArrayStub stub(
1493 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
1494 __ CallStub(&stub);
1495 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1496 } else if (expr->depth() > 1) {
1497 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1488 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1498 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1489 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1499 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); 1490 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1500 } else { 1491 } else {
1501 ASSERT(constant_elements_kind == FAST_ELEMENTS || 1492 ASSERT(constant_elements_kind == FAST_ELEMENTS ||
1502 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS || 1493 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS ||
1503 FLAG_smi_only_arrays); 1494 FLAG_smi_only_arrays);
1504 FastCloneShallowArrayStub::Mode mode = 1495 if (constant_elements_values->map() ==
1505 constant_elements_kind == FAST_DOUBLE_ELEMENTS 1496 isolate()->heap()->fixed_cow_array_map()) {
1506 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 1497 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(),
1507 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 1498 1);
1508 FastCloneShallowArrayStub stub(mode, length); 1499 }
1500 FastCloneShallowArrayStub stub(
1501 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS, length);
1509 __ CallStub(&stub); 1502 __ CallStub(&stub);
1510 } 1503 }
1511 1504
1512 bool result_saved = false; // Is the result saved to the stack? 1505 bool result_saved = false; // Is the result saved to the stack?
1513 1506
1514 // Emit code to evaluate all the non-constant subexpressions and to store 1507 // Emit code to evaluate all the non-constant subexpressions and to store
1515 // them into the newly cloned array. 1508 // them into the newly cloned array.
1516 for (int i = 0; i < length; i++) { 1509 for (int i = 0; i < length; i++) {
1517 Expression* subexpr = subexprs->at(i); 1510 Expression* subexpr = subexprs->at(i);
1518 // If the subexpression is a literal or a simple materialized literal it 1511 // If the subexpression is a literal or a simple materialized literal it
(...skipping 2824 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 *context_length = 0; 4336 *context_length = 0;
4344 return previous_; 4337 return previous_;
4345 } 4338 }
4346 4339
4347 4340
4348 #undef __ 4341 #undef __
4349 4342
4350 } } // namespace v8::internal 4343 } } // namespace v8::internal
4351 4344
4352 #endif // V8_TARGET_ARCH_IA32 4345 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698